diff options
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 3 | ||||
-rw-r--r-- | Alc/ALu.c | 11 | ||||
-rw-r--r-- | Alc/alcEcho.c | 7 | ||||
-rw-r--r-- | Alc/alcReverb.c | 11 |
4 files changed, 17 insertions, 15 deletions
@@ -546,9 +546,6 @@ static ALvoid InitContext(ALCcontext *pContext) pContext->LastError = AL_NO_ERROR; pContext->InUse = AL_FALSE; - //Set output format - pContext->Frequency = pContext->Device->Frequency; - //Set globals pContext->DistanceModel = AL_INVERSE_DISTANCE_CLAMPED; pContext->DopplerFactor = 1.0f; @@ -798,13 +798,16 @@ static void MixSomeSources(ALCcontext *ALContext, float (*DryBuffer)[OUTPUTCHANN ALfloat DryGainHF = 0.0f; ALfloat WetGainHF[MAX_SENDS]; ALuint rampLength; + ALuint frequency; ALint Looping,State; ALint increment; if(!(ALSource=ALContext->Source)) return; - rampLength = ALContext->Frequency * MIN_RAMP_LENGTH / 1000; + frequency = ALContext->Device->Frequency; + + rampLength = frequency * MIN_RAMP_LENGTH / 1000; rampLength = max(rampLength, SamplesToDo); another_source: @@ -850,7 +853,7 @@ another_source: CalcSourceParams(ALContext, ALSource, (Channels==1)?AL_TRUE:AL_FALSE, DrySend, WetSend, &Pitch, &DryGainHF, WetGainHF); - Pitch = (Pitch*Frequency) / ALContext->Frequency; + Pitch = (Pitch*Frequency) / frequency; if(Channels == 1) { @@ -858,7 +861,7 @@ another_source: /* Update filter coefficients. Calculations based on the I3DL2 * spec. */ - cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / ALContext->Frequency); + cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / frequency); /* We use four chained one-pole filters, so we need to take the * fourth root of the squared gain, which is the same as the square * root of the base gain. */ @@ -888,7 +891,7 @@ another_source: ALfloat cw, a, g; /* Multi-channel sources use two chained one-pole filters */ - cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / ALContext->Frequency); + cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / frequency); g = __max(DryGainHF, 0.01f); a = 0.0f; if(g < 0.9999f) /* 1-epsilon */ diff --git a/Alc/alcEcho.c b/Alc/alcEcho.c index 6601051d..431fa08e 100644 --- a/Alc/alcEcho.c +++ b/Alc/alcEcho.c @@ -118,10 +118,11 @@ ALboolean EchoDeviceUpdate(ALeffectState *effect, ALCdevice *Device) ALvoid EchoUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect) { ALechoState *state = (ALechoState*)effect; + ALuint frequency = Context->Device->Frequency; ALfloat lrpan, cw, a, g; - state->Tap[0].delay = (ALuint)(Effect->Echo.Delay * Context->Frequency); - state->Tap[1].delay = (ALuint)(Effect->Echo.LRDelay * Context->Frequency); + state->Tap[0].delay = (ALuint)(Effect->Echo.Delay * frequency); + state->Tap[1].delay = (ALuint)(Effect->Echo.LRDelay * frequency); state->Tap[1].delay += state->Tap[0].delay; lrpan = Effect->Echo.Spread*0.5f + 0.5f; @@ -130,7 +131,7 @@ ALvoid EchoUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Ef state->FeedGain = Effect->Echo.Feedback; - cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / Context->Frequency); + cw = cos(2.0*M_PI * LOWPASSFREQCUTOFF / frequency); g = 1.0f - Effect->Echo.Damping; a = 0.0f; if(g < 0.9999f) // 1-epsilon diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c index 4126b3e4..7579933e 100644 --- a/Alc/alcReverb.c +++ b/Alc/alcReverb.c @@ -474,12 +474,13 @@ ALboolean VerbDeviceUpdate(ALeffectState *effect, ALCdevice *Device) ALvoid VerbUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Effect) { ALverbState *State = (ALverbState*)effect; + ALuint frequency = Context->Device->Frequency; ALuint index; ALfloat length, mixCoeff, cw, g, coeff; ALfloat hfRatio = Effect->Reverb.DecayHFRatio; // Calculate the master low-pass filter (from the master effect HF gain). - cw = cos(2.0 * M_PI * Effect->Reverb.HFReference / Context->Frequency); + cw = cos(2.0*M_PI * Effect->Reverb.HFReference / frequency); g = __max(Effect->Reverb.GainHF, 0.0001f); State->LpFilter.coeff = 0.0f; if(g < 0.9999f) // 1-epsilon @@ -487,7 +488,7 @@ ALvoid VerbUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Ef // Calculate the initial delay taps. length = Effect->Reverb.ReflectionsDelay; - State->Tap[0] = (ALuint)(length * Context->Frequency); + State->Tap[0] = (ALuint)(length * frequency); length += Effect->Reverb.LateReverbDelay; @@ -504,7 +505,7 @@ ALvoid VerbUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Ef length += LATE_LINE_LENGTH[0] * (1.0f + (Effect->Reverb.Density * LATE_LINE_MULTIPLIER)) * (DECO_FRACTION * (pow(DECO_MULTIPLIER, (ALfloat)index) - 1.0f)); - State->Tap[1 + index] = (ALuint)(length * Context->Frequency); + State->Tap[1 + index] = (ALuint)(length * frequency); } // Calculate the early reflections gain (from the master effect gain, and @@ -596,7 +597,7 @@ ALvoid VerbUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Ef } // Calculate the low-pass filter frequency. - cw = cos(2.0f * M_PI * Effect->Reverb.HFReference / Context->Frequency); + cw = cos(2.0*M_PI * Effect->Reverb.HFReference / frequency); for(index = 0;index < 4;index++) { @@ -604,7 +605,7 @@ ALvoid VerbUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffect *Ef length = LATE_LINE_LENGTH[index] * (1.0f + (Effect->Reverb.Density * LATE_LINE_MULTIPLIER)); // Calculate the delay offset for the cyclical delay lines. - State->Late.Offset[index] = (ALuint)(length * Context->Frequency); + State->Late.Offset[index] = (ALuint)(length * frequency); // Calculate the gain (coefficient) for each cyclical line. State->Late.Coeff[index] = pow(10.0f, length / Effect->Reverb.DecayTime * |