aboutsummaryrefslogtreecommitdiffstats
path: root/Alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-05-21 02:43:59 -0700
committerChris Robinson <[email protected]>2013-05-21 02:43:59 -0700
commitfba9ac6db1d1d1bff066befe48f75c64aead3587 (patch)
tree78527495cb4e67fb9888ac441fd266f425562619 /Alc
parentde387c853f00af409fc2cdceb0736f60934389c2 (diff)
Avoid storing the device frequency in the distortion state
Diffstat (limited to 'Alc')
-rw-r--r--Alc/alcDistortion.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/Alc/alcDistortion.c b/Alc/alcDistortion.c
index c431a2ca..0b0c9c93 100644
--- a/Alc/alcDistortion.c
+++ b/Alc/alcDistortion.c
@@ -55,7 +55,6 @@ typedef struct ALdistortionState {
/* Effect parameters */
ALEQFilter bandpass;
ALEQFilter lowpass;
- ALfloat frequency;
ALfloat attenuation;
ALfloat edge_coeff;
} ALdistortionState;
@@ -68,17 +67,16 @@ static ALvoid DistortionDestroy(ALeffectState *effect)
static ALboolean DistortionDeviceUpdate(ALeffectState *effect, ALCdevice *Device)
{
- ALdistortionState *state = STATIC_UPCAST(ALdistortionState, ALeffectState, effect);
-
- state->frequency = (ALfloat)Device->Frequency;
-
return AL_TRUE;
+ (void)effect;
+ (void)Device;
}
static ALvoid DistortionUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffectslot *Slot)
{
ALdistortionState *state = STATIC_UPCAST(ALdistortionState, ALeffectState, effect);
ALfloat gain = sqrtf(1.0f / Device->NumChan) * Slot->Gain;
+ ALfloat frequency = (ALfloat)Device->Frequency;
ALuint it;
ALfloat w0;
ALfloat alpha;
@@ -105,7 +103,7 @@ static ALvoid DistortionUpdate(ALeffectState *effect, ALCdevice *Device, const A
cutoff = Slot->effect.Distortion.LowpassCutoff;
/* Bandwidth value is constant in octaves */
bandwidth = (cutoff / 2.0f) / (cutoff * 0.67f);
- w0 = 2.0f * F_PI * cutoff / (state->frequency * 4.0f);
+ w0 = 2.0f*F_PI * cutoff / (frequency*4.0f);
alpha = sinf(w0) * sinhf(logf(2.0f) / 2.0f * bandwidth * w0 / sinf(w0));
state->lowpass.b[0] = (1.0f - cosf(w0)) / 2.0f;
state->lowpass.b[1] = 1.0f - cosf(w0);
@@ -118,7 +116,7 @@ static ALvoid DistortionUpdate(ALeffectState *effect, ALCdevice *Device, const A
cutoff = Slot->effect.Distortion.EQCenter;
/* Convert bandwidth in Hz to octaves */
bandwidth = Slot->effect.Distortion.EQBandwidth / (cutoff * 0.67f);
- w0 = 2.0f * F_PI * cutoff / (state->frequency * 4.0f);
+ w0 = 2.0f*F_PI * cutoff / (frequency*4.0f);
alpha = sinf(w0) * sinhf(logf(2.0f) / 2.0f * bandwidth * w0 / sinf(w0));
state->bandpass.b[0] = alpha;
state->bandpass.b[1] = 0;