Simplify and fix some filter gain calculations
This commit is contained in:
@@ -452,7 +452,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
|
||||
}
|
||||
|
||||
{
|
||||
ALfloat gain = maxf(0.001f, DryGainHF);
|
||||
ALfloat gain = maxf(0.001f, sqrtf(DryGainHF));
|
||||
for(c = 0;c < num_channels;c++)
|
||||
ALfilterState_setParams(&ALSource->Params.Direct.Filter[c],
|
||||
ALfilterType_LowPass, gain,
|
||||
@@ -460,7 +460,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
|
||||
}
|
||||
for(i = 0;i < NumSends;i++)
|
||||
{
|
||||
ALfloat gain = maxf(0.001f, WetGainHF[i]);
|
||||
ALfloat gain = maxf(0.001f, sqrtf(WetGainHF[i]));
|
||||
for(c = 0;c < num_channels;c++)
|
||||
ALfilterState_setParams(&ALSource->Params.Send[i].Filter[c],
|
||||
ALfilterType_LowPass, gain,
|
||||
@@ -901,13 +901,19 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
|
||||
ALSource->Params.Send[i].Gain = WetGain[i];
|
||||
|
||||
|
||||
ALfilterState_setParams(&ALSource->Params.Direct.Filter[0],
|
||||
ALfilterType_LowPass, maxf(0.001f, DryGainHF),
|
||||
(ALfloat)LOWPASSFREQREF/Frequency, 0.0f);
|
||||
for(i = 0;i < NumSends;i++)
|
||||
ALfilterState_setParams(&ALSource->Params.Send[i].Filter[0],
|
||||
ALfilterType_LowPass, maxf(0.001f, WetGainHF[i]),
|
||||
{
|
||||
ALfloat gain = maxf(0.001f, sqrtf(DryGainHF));
|
||||
ALfilterState_setParams(&ALSource->Params.Direct.Filter[0],
|
||||
ALfilterType_LowPass, gain,
|
||||
(ALfloat)LOWPASSFREQREF/Frequency, 0.0f);
|
||||
}
|
||||
for(i = 0;i < NumSends;i++)
|
||||
{
|
||||
ALfloat gain = maxf(0.001f, sqrtf(WetGainHF[i]));
|
||||
ALfilterState_setParams(&ALSource->Params.Send[i].Filter[0],
|
||||
ALfilterType_LowPass, gain,
|
||||
(ALfloat)LOWPASSFREQREF/Frequency, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -123,27 +123,27 @@ static ALvoid ALequalizerState_Update(ALequalizerState *state, ALCdevice *device
|
||||
ALfloat gain;
|
||||
|
||||
/* convert linear gains to filter gains */
|
||||
switch (it)
|
||||
switch(it)
|
||||
{
|
||||
case 0: /* Low Shelf */
|
||||
gain = powf(10.0f, (20.0f * log10f(slot->EffectProps.Equalizer.LowGain)) / 40.0f);
|
||||
gain = sqrtf(slot->EffectProps.Equalizer.LowGain);
|
||||
filter_frequency = slot->EffectProps.Equalizer.LowCutoff;
|
||||
type = ALfilterType_LowShelf;
|
||||
break;
|
||||
case 1: /* Peaking */
|
||||
gain = powf(10.0f, (20.0f * log10f(slot->EffectProps.Equalizer.Mid1Gain)) / 40.0f);
|
||||
gain = sqrtf(slot->EffectProps.Equalizer.Mid1Gain);
|
||||
filter_frequency = slot->EffectProps.Equalizer.Mid1Center;
|
||||
bandwidth = slot->EffectProps.Equalizer.Mid1Width;
|
||||
type = ALfilterType_Peaking;
|
||||
break;
|
||||
case 2: /* Peaking */
|
||||
gain = powf(10.0f, (20.0f * log10f(slot->EffectProps.Equalizer.Mid2Gain)) / 40.0f);
|
||||
gain = sqrtf(slot->EffectProps.Equalizer.Mid2Gain);
|
||||
filter_frequency = slot->EffectProps.Equalizer.Mid2Center;
|
||||
bandwidth = slot->EffectProps.Equalizer.Mid2Width;
|
||||
type = ALfilterType_Peaking;
|
||||
break;
|
||||
case 3: /* High Shelf */
|
||||
gain = powf(10.0f, (20.0f * log10f(slot->EffectProps.Equalizer.HighGain)) / 40.0f);
|
||||
gain = sqrtf(slot->EffectProps.Equalizer.HighGain);
|
||||
filter_frequency = slot->EffectProps.Equalizer.HighCutoff;
|
||||
type = ALfilterType_HighShelf;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user