diff options
author | Chris Robinson <[email protected]> | 2010-05-12 04:56:03 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-05-12 04:56:03 -0700 |
commit | e3a70e50216850aff2721ce3cc4a3e1c2cee311f (patch) | |
tree | bb9a7f3bbd9ff90903f14360ab127eb1b6275ce2 /Alc/alcReverb.c | |
parent | af4faaf6660d02ce593e07b97d05020b44ed06e4 (diff) |
Scale output of effects to compensate for device down-mixing
Diffstat (limited to 'Alc/alcReverb.c')
-rw-r--r-- | Alc/alcReverb.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Alc/alcReverb.c b/Alc/alcReverb.c index 3529c08d..6ca47d2d 100644 --- a/Alc/alcReverb.c +++ b/Alc/alcReverb.c @@ -129,6 +129,9 @@ typedef struct ALverbState { } Echo; // The current read offset for all delay lines. ALuint Offset; + + // Gain scale to account for device down-mixing + ALfloat Scale; } ALverbState; /* This coefficient is used to define the maximum frequency range controlled @@ -987,6 +990,8 @@ static ALboolean VerbDeviceUpdate(ALeffectState *effect, ALCdevice *Device) if(!AllocLines(AL_FALSE, frequency, State)) return AL_FALSE; + State->Scale = aluSqrt(Device->NumChan / 8.0f); + // The early reflection and late all-pass filter line lengths are static, // so their offsets only need to be calculated once. for(index = 0;index < 4;index++) @@ -1012,6 +1017,8 @@ static ALboolean EAXVerbDeviceUpdate(ALeffectState *effect, ALCdevice *Device) if(!AllocLines(AL_TRUE, frequency, State)) return AL_FALSE; + State->Scale = aluSqrt(Device->NumChan / 8.0f); + // Calculate the modulation filter coefficient. Notice that the exponent // is calculated given the current sample rate. This ensures that the // resulting filter response over time is consistent across all sample @@ -1141,7 +1148,7 @@ static ALvoid VerbProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuin ALverbState *State = (ALverbState*)effect; ALuint index; ALfloat early[4], late[4], out[4]; - ALfloat gain = Slot->Gain; + ALfloat gain = Slot->Gain * State->Scale; for(index = 0;index < SamplesToDo;index++) { @@ -1173,7 +1180,7 @@ static ALvoid EAXVerbProcess(ALeffectState *effect, const ALeffectslot *Slot, AL ALverbState *State = (ALverbState*)effect; ALuint index; ALfloat early[4], late[4]; - ALfloat gain = Slot->Gain; + ALfloat gain = Slot->Gain * State->Scale; for(index = 0;index < SamplesToDo;index++) { @@ -1304,6 +1311,8 @@ ALeffectState *VerbCreate(void) State->Offset = 0; + State->Scale = 1.0f; + return &State->state; } |