diff options
author | Chris Robinson <[email protected]> | 2013-05-29 22:34:57 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2013-05-29 22:34:57 -0700 |
commit | a7a3d1e1947186f86cb4bdcfbeea0970d2726683 (patch) | |
tree | cc17ddb1acad39fea61fcc5aae7c471eb294c2d7 /Alc | |
parent | 9c3f1d11f0dd28feb43fb903bce7cf2362409abb (diff) |
Avoid an unnecessary loop
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/effects/equalizer.c | 55 |
1 files changed, 19 insertions, 36 deletions
diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c index 467dbbbc..fd79462f 100644 --- a/Alc/effects/equalizer.c +++ b/Alc/effects/equalizer.c @@ -115,42 +115,25 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, ALCdevice *device } /* Calculate coefficients for the each type of filter */ - for(it = 0; it < 4; it++) - { - ALfilterType type = ALfilterType_Peaking; - ALfloat filter_frequency; - ALfloat bandwidth = 0.0f; - ALfloat gain; - - /* convert linear gains to filter gains */ - switch(it) - { - case 0: /* Low Shelf */ - gain = sqrtf(slot->EffectProps.Equalizer.LowGain); - filter_frequency = slot->EffectProps.Equalizer.LowCutoff; - type = ALfilterType_LowShelf; - break; - case 1: /* Peaking */ - 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 = 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 = sqrtf(slot->EffectProps.Equalizer.HighGain); - filter_frequency = slot->EffectProps.Equalizer.HighCutoff; - type = ALfilterType_HighShelf; - break; - } - - ALfilterState_setParams(&state->filter[it], type, gain, filter_frequency/frequency, bandwidth); - } + ALfilterState_setParams(&state->filter[0], ALfilterType_LowShelf, + sqrtf(slot->EffectProps.Equalizer.LowGain), + slot->EffectProps.Equalizer.LowCutoff/frequency, + 0.0f); + + ALfilterState_setParams(&state->filter[1], ALfilterType_Peaking, + sqrtf(slot->EffectProps.Equalizer.Mid1Gain), + slot->EffectProps.Equalizer.Mid1Center/frequency, + slot->EffectProps.Equalizer.Mid1Width); + + ALfilterState_setParams(&state->filter[2], ALfilterType_Peaking, + sqrtf(slot->EffectProps.Equalizer.Mid2Gain), + slot->EffectProps.Equalizer.Mid2Center/frequency, + slot->EffectProps.Equalizer.Mid2Width); + + ALfilterState_setParams(&state->filter[3], ALfilterType_HighShelf, + sqrtf(slot->EffectProps.Equalizer.HighGain), + slot->EffectProps.Equalizer.HighCutoff/frequency, + 0.0f); } static ALvoid ALequalizerState_process(ALequalizerState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE]) |