aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/ALu.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-05-21 03:38:19 -0700
committerChris Robinson <[email protected]>2017-05-21 03:38:19 -0700
commit95ea3fdd05d55020c056e549c74def62c508e761 (patch)
tree1a118ea92e89d07ea9bf1775fc5c54998c301ab9 /Alc/ALu.c
parent5691dceb38d7dfa6159c9c9b5358d094acc7e8a4 (diff)
Avoid calculating the filter coefficients multiple times
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r--Alc/ALu.c60
1 files changed, 36 insertions, 24 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 22aca28a..28dfd7c1 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -953,19 +953,25 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Distance, const
ALfloat lfScale = props->Direct.LFReference / Frequency;
ALfloat gainHF = maxf(DryGainHF, 0.001f); /* Limit -60dB */
ALfloat gainLF = maxf(DryGainLF, 0.001f);
- for(c = 0;c < num_channels;c++)
+
+ voice->Direct.Params[0].FilterType = AF_None;
+ if(gainHF != 1.0f) voice->Direct.Params[0].FilterType |= AF_LowPass;
+ if(gainLF != 1.0f) voice->Direct.Params[0].FilterType |= AF_HighPass;
+ ALfilterState_setParams(
+ &voice->Direct.Params[0].LowPass, ALfilterType_HighShelf,
+ gainHF, hfScale, calc_rcpQ_from_slope(gainHF, 1.0f)
+ );
+ ALfilterState_setParams(
+ &voice->Direct.Params[0].HighPass, ALfilterType_LowShelf,
+ gainLF, lfScale, calc_rcpQ_from_slope(gainLF, 1.0f)
+ );
+ for(c = 1;c < num_channels;c++)
{
- voice->Direct.Params[c].FilterType = AF_None;
- if(gainHF != 1.0f) voice->Direct.Params[c].FilterType |= AF_LowPass;
- if(gainLF != 1.0f) voice->Direct.Params[c].FilterType |= AF_HighPass;
- ALfilterState_setParams(
- &voice->Direct.Params[c].LowPass, ALfilterType_HighShelf,
- gainHF, hfScale, calc_rcpQ_from_slope(gainHF, 1.0f)
- );
- ALfilterState_setParams(
- &voice->Direct.Params[c].HighPass, ALfilterType_LowShelf,
- gainLF, lfScale, calc_rcpQ_from_slope(gainLF, 1.0f)
- );
+ voice->Direct.Params[c].FilterType = voice->Direct.Params[0].FilterType;
+ ALfilterState_copyParams(&voice->Direct.Params[c].LowPass,
+ &voice->Direct.Params[0].LowPass);
+ ALfilterState_copyParams(&voice->Direct.Params[c].HighPass,
+ &voice->Direct.Params[0].HighPass);
}
}
for(i = 0;i < NumSends;i++)
@@ -974,19 +980,25 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Distance, const
ALfloat lfScale = props->Send[i].LFReference / Frequency;
ALfloat gainHF = maxf(WetGainHF[i], 0.001f);
ALfloat gainLF = maxf(WetGainLF[i], 0.001f);
- for(c = 0;c < num_channels;c++)
+
+ voice->Send[i].Params[0].FilterType = AF_None;
+ if(gainHF != 1.0f) voice->Send[i].Params[0].FilterType |= AF_LowPass;
+ if(gainLF != 1.0f) voice->Send[i].Params[0].FilterType |= AF_HighPass;
+ ALfilterState_setParams(
+ &voice->Send[i].Params[0].LowPass, ALfilterType_HighShelf,
+ gainHF, hfScale, calc_rcpQ_from_slope(gainHF, 1.0f)
+ );
+ ALfilterState_setParams(
+ &voice->Send[i].Params[0].HighPass, ALfilterType_LowShelf,
+ gainLF, lfScale, calc_rcpQ_from_slope(gainLF, 1.0f)
+ );
+ for(c = 1;c < num_channels;c++)
{
- voice->Send[i].Params[c].FilterType = AF_None;
- if(gainHF != 1.0f) voice->Send[i].Params[c].FilterType |= AF_LowPass;
- if(gainLF != 1.0f) voice->Send[i].Params[c].FilterType |= AF_HighPass;
- ALfilterState_setParams(
- &voice->Send[i].Params[c].LowPass, ALfilterType_HighShelf,
- gainHF, hfScale, calc_rcpQ_from_slope(gainHF, 1.0f)
- );
- ALfilterState_setParams(
- &voice->Send[i].Params[c].HighPass, ALfilterType_LowShelf,
- gainLF, lfScale, calc_rcpQ_from_slope(gainLF, 1.0f)
- );
+ voice->Send[i].Params[c].FilterType = voice->Send[i].Params[0].FilterType;
+ ALfilterState_copyParams(&voice->Send[i].Params[c].LowPass,
+ &voice->Send[i].Params[0].LowPass);
+ ALfilterState_copyParams(&voice->Send[i].Params[c].HighPass,
+ &voice->Send[i].Params[0].HighPass);
}
}
}