Use the high-shelf filter in place of low-pass

They effectively both work to lower (or raise) high frequencies. However, the
high-shelf performs better when gain=1.
This commit is contained in:
Chris Robinson 2013-05-28 10:57:38 -07:00
parent 6556626055
commit 48aa1e10d6
5 changed files with 6 additions and 19 deletions

View File

@ -455,7 +455,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
ALfloat gain = maxf(0.001f, sqrtf(DryGainHF));
for(c = 0;c < num_channels;c++)
ALfilterState_setParams(&ALSource->Params.Direct.Filter[c],
ALfilterType_LowPass, gain,
ALfilterType_HighShelf, gain,
(ALfloat)LOWPASSFREQREF/Frequency, 0.0f);
}
for(i = 0;i < NumSends;i++)
@ -463,7 +463,7 @@ ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
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,
ALfilterType_HighShelf, gain,
(ALfloat)LOWPASSFREQREF/Frequency, 0.0f);
}
}
@ -904,14 +904,14 @@ ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext)
{
ALfloat gain = maxf(0.001f, sqrtf(DryGainHF));
ALfilterState_setParams(&ALSource->Params.Direct.Filter[0],
ALfilterType_LowPass, gain,
ALfilterType_HighShelf, 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,
ALfilterType_HighShelf, gain,
(ALfloat)LOWPASSFREQREF/Frequency, 0.0f);
}
}

View File

@ -104,7 +104,7 @@ static ALvoid ALechoState_Update(ALechoState *state, ALCdevice *Device, const AL
state->FeedGain = Slot->EffectProps.Echo.Feedback;
ALfilterState_setParams(&state->Filter, ALfilterType_LowPass,
ALfilterState_setParams(&state->Filter, ALfilterType_HighShelf,
1.0f - Slot->EffectProps.Echo.Damping,
(ALfloat)LOWPASSFREQREF/frequency, 0.0f);

View File

@ -1095,7 +1095,7 @@ static ALvoid ALreverbState_Update(ALreverbState *State, ALCdevice *Device, cons
freq_scale = Slot->EffectProps.Reverb.HFReference / frequency;
else
freq_scale = (ALfloat)LOWPASSFREQREF / frequency;
ALfilterState_setParams(&State->LpFilter, ALfilterType_LowPass,
ALfilterState_setParams(&State->LpFilter, ALfilterType_HighShelf,
Slot->EffectProps.Reverb.GainHF,
freq_scale, 0.0f);

View File

@ -16,8 +16,6 @@ ALfloat lpCoeffCalc(ALfloat g, ALfloat cw);
typedef enum ALfilterType {
ALfilterType_LowPass,
ALfilterType_HighShelf,
ALfilterType_LowShelf,
ALfilterType_Peaking,

View File

@ -343,17 +343,6 @@ void ALfilterState_setParams(ALfilterState *filter, ALfilterType type, ALfloat g
/* Calculate filter coefficients depending on filter type */
switch(type)
{
case ALfilterType_LowPass:
alpha = sinf(w0) / 2.0f * sqrtf((gain + 1.0f/gain) *
(1.0f/0.75f - 1.0f) + 2.0f);
filter->b[0] = (1.0f - cosf(w0)) * 0.5f;
filter->b[1] = 1.0f - cosf(w0);
filter->b[2] = (1.0f - cosf(w0)) * 0.5f;
filter->a[0] = 1.0f + alpha;
filter->a[1] = -2.0f*cosf(w0);
filter->a[2] = 1.0f - alpha;
break;
case ALfilterType_HighShelf:
alpha = sinf(w0) / 2.0f * sqrtf((gain + 1.0f/gain) *
(1.0f/0.75f - 1.0f) + 2.0f);