diff options
author | Chris Robinson <[email protected]> | 2016-01-25 06:11:51 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-01-25 06:11:51 -0800 |
commit | f547ef6d391be5e0cd3e0477c3f8de859a47df69 (patch) | |
tree | d135e13f3a204af7eaac97a71744e308da661fe2 /Alc/effects | |
parent | 79e0f3e747880a3e7d8342a8602b796b84c0f322 (diff) |
Separate calculating ambisonic coefficients from the panning gains
Diffstat (limited to 'Alc/effects')
-rw-r--r-- | Alc/effects/autowah.c | 4 | ||||
-rw-r--r-- | Alc/effects/chorus.c | 11 | ||||
-rw-r--r-- | Alc/effects/compressor.c | 4 | ||||
-rw-r--r-- | Alc/effects/dedicated.c | 7 | ||||
-rw-r--r-- | Alc/effects/distortion.c | 4 | ||||
-rw-r--r-- | Alc/effects/echo.c | 12 | ||||
-rw-r--r-- | Alc/effects/equalizer.c | 4 | ||||
-rw-r--r-- | Alc/effects/flanger.c | 11 | ||||
-rw-r--r-- | Alc/effects/modulator.c | 4 | ||||
-rw-r--r-- | Alc/effects/null.c | 2 | ||||
-rw-r--r-- | Alc/effects/reverb.c | 19 |
11 files changed, 47 insertions, 35 deletions
diff --git a/Alc/effects/autowah.c b/Alc/effects/autowah.c index e97083e0..2da75c56 100644 --- a/Alc/effects/autowah.c +++ b/Alc/effects/autowah.c @@ -63,7 +63,7 @@ static ALboolean ALautowahState_deviceUpdate(ALautowahState *state, ALCdevice *d return AL_TRUE; } -static ALvoid ALautowahState_update(ALautowahState *state, ALCdevice *device, const ALeffectslot *slot) +static ALvoid ALautowahState_update(ALautowahState *state, const ALCdevice *device, const ALeffectslot *slot) { ALfloat attackTime, releaseTime; @@ -75,7 +75,7 @@ static ALvoid ALautowahState_update(ALautowahState *state, ALCdevice *device, co state->PeakGain = slot->EffectProps.Autowah.PeakGain; state->Resonance = slot->EffectProps.Autowah.Resonance; - ComputeAmbientGains(device, slot->Gain, state->Gain); + ComputeAmbientGains(device->AmbiCoeffs, device->NumChannels, slot->Gain, state->Gain); } static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/Alc/effects/chorus.c b/Alc/effects/chorus.c index 7aa5898b..1477d58b 100644 --- a/Alc/effects/chorus.c +++ b/Alc/effects/chorus.c @@ -91,11 +91,10 @@ static ALboolean ALchorusState_deviceUpdate(ALchorusState *state, ALCdevice *Dev return AL_TRUE; } -static ALvoid ALchorusState_update(ALchorusState *state, ALCdevice *Device, const ALeffectslot *Slot) +static ALvoid ALchorusState_update(ALchorusState *state, const ALCdevice *Device, const ALeffectslot *Slot) { - static const ALfloat left_dir[3] = { -1.0f, 0.0f, 0.0f }; - static const ALfloat right_dir[3] = { 1.0f, 0.0f, 0.0f }; ALfloat frequency = (ALfloat)Device->Frequency; + ALfloat coeffs[MAX_AMBI_COEFFS]; ALfloat rate; ALint phase; @@ -113,8 +112,10 @@ static ALvoid ALchorusState_update(ALchorusState *state, ALCdevice *Device, cons state->delay = fastf2i(Slot->EffectProps.Chorus.Delay * frequency); /* Gains for left and right sides */ - ComputeDirectionalGains(Device, left_dir, Slot->Gain, state->Gain[0]); - ComputeDirectionalGains(Device, right_dir, Slot->Gain, state->Gain[1]); + CalcXYZCoeffs(-1.0f, 0.0f, 0.0f, coeffs); + ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, Slot->Gain, state->Gain[0]); + CalcXYZCoeffs( 1.0f, 0.0f, 0.0f, coeffs); + ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, Slot->Gain, state->Gain[1]); phase = Slot->EffectProps.Chorus.Phase; rate = Slot->EffectProps.Chorus.Rate; diff --git a/Alc/effects/compressor.c b/Alc/effects/compressor.c index 9859a085..52a6324d 100644 --- a/Alc/effects/compressor.c +++ b/Alc/effects/compressor.c @@ -55,11 +55,11 @@ static ALboolean ALcompressorState_deviceUpdate(ALcompressorState *state, ALCdev return AL_TRUE; } -static ALvoid ALcompressorState_update(ALcompressorState *state, ALCdevice *device, const ALeffectslot *slot) +static ALvoid ALcompressorState_update(ALcompressorState *state, const ALCdevice *device, const ALeffectslot *slot) { state->Enabled = slot->EffectProps.Compressor.OnOff; - ComputeAmbientGains(device, slot->Gain, state->Gain); + ComputeAmbientGains(device->AmbiCoeffs, device->NumChannels, slot->Gain, state->Gain); } static ALvoid ALcompressorState_process(ALcompressorState *state, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/Alc/effects/dedicated.c b/Alc/effects/dedicated.c index dc581ace..fdc20601 100644 --- a/Alc/effects/dedicated.c +++ b/Alc/effects/dedicated.c @@ -45,7 +45,7 @@ static ALboolean ALdedicatedState_deviceUpdate(ALdedicatedState *UNUSED(state), return AL_TRUE; } -static ALvoid ALdedicatedState_update(ALdedicatedState *state, ALCdevice *device, const ALeffectslot *Slot) +static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCdevice *device, const ALeffectslot *Slot) { ALfloat Gain; ALuint i; @@ -69,8 +69,9 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, ALCdevice *device state->gains[idx] = Gain; else { - static const ALfloat front_dir[3] = { 0.0f, 0.0f, -1.0f }; - ComputeDirectionalGains(device, front_dir, Gain, state->gains); + ALfloat coeffs[MAX_AMBI_COEFFS]; + CalcXYZCoeffs(0.0f, 0.0f, -1.0f, coeffs); + ComputePanningGains(device->AmbiCoeffs, device->NumChannels, coeffs, Gain, state->gains); } } } diff --git a/Alc/effects/distortion.c b/Alc/effects/distortion.c index 221cec39..dc2e280a 100644 --- a/Alc/effects/distortion.c +++ b/Alc/effects/distortion.c @@ -52,7 +52,7 @@ static ALboolean ALdistortionState_deviceUpdate(ALdistortionState *UNUSED(state) return AL_TRUE; } -static ALvoid ALdistortionState_update(ALdistortionState *state, ALCdevice *Device, const ALeffectslot *Slot) +static ALvoid ALdistortionState_update(ALdistortionState *state, const ALCdevice *Device, const ALeffectslot *Slot) { ALfloat frequency = (ALfloat)Device->Frequency; ALfloat bandwidth; @@ -83,7 +83,7 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, ALCdevice *Devi cutoff / (frequency*4.0f), calc_rcpQ_from_bandwidth(cutoff / (frequency*4.0f), bandwidth) ); - ComputeAmbientGains(Device, Slot->Gain, state->Gain); + ComputeAmbientGains(Device->AmbiCoeffs, Device->NumChannels, Slot->Gain, state->Gain); } static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/Alc/effects/echo.c b/Alc/effects/echo.c index f5a53c36..e2bb6407 100644 --- a/Alc/effects/echo.c +++ b/Alc/effects/echo.c @@ -81,10 +81,10 @@ static ALboolean ALechoState_deviceUpdate(ALechoState *state, ALCdevice *Device) return AL_TRUE; } -static ALvoid ALechoState_update(ALechoState *state, ALCdevice *Device, const ALeffectslot *Slot) +static ALvoid ALechoState_update(ALechoState *state, const ALCdevice *Device, const ALeffectslot *Slot) { - ALfloat pandir[3] = { 0.0f, 0.0f, 0.0f }; ALuint frequency = Device->Frequency; + ALfloat coeffs[MAX_AMBI_COEFFS]; ALfloat gain, lrpan; state->Tap[0].delay = fastf2u(Slot->EffectProps.Echo.Delay * frequency) + 1; @@ -103,12 +103,12 @@ static ALvoid ALechoState_update(ALechoState *state, ALCdevice *Device, const AL gain = Slot->Gain; /* First tap panning */ - pandir[0] = -lrpan; - ComputeDirectionalGains(Device, pandir, gain, state->Gain[0]); + CalcXYZCoeffs(-lrpan, 0.0f, 0.0f, coeffs); + ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, gain, state->Gain[0]); /* Second tap panning */ - pandir[0] = +lrpan; - ComputeDirectionalGains(Device, pandir, gain, state->Gain[1]); + CalcXYZCoeffs( lrpan, 0.0f, 0.0f, coeffs); + ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, gain, state->Gain[1]); } static ALvoid ALechoState_process(ALechoState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c index 244667ab..4f7846fd 100644 --- a/Alc/effects/equalizer.c +++ b/Alc/effects/equalizer.c @@ -90,12 +90,12 @@ static ALboolean ALequalizerState_deviceUpdate(ALequalizerState *UNUSED(state), return AL_TRUE; } -static ALvoid ALequalizerState_update(ALequalizerState *state, ALCdevice *device, const ALeffectslot *slot) +static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice *device, const ALeffectslot *slot) { ALfloat frequency = (ALfloat)device->Frequency; ALfloat gain, freq_mult; - ComputeAmbientGains(device, slot->Gain, state->Gain); + ComputeAmbientGains(device->AmbiCoeffs, device->NumChannels, slot->Gain, state->Gain); /* Calculate coefficients for the each type of filter. Note that the shelf * filters' gain is for the reference frequency, which is the centerpoint diff --git a/Alc/effects/flanger.c b/Alc/effects/flanger.c index f6191abd..5fcc8be8 100644 --- a/Alc/effects/flanger.c +++ b/Alc/effects/flanger.c @@ -91,11 +91,10 @@ static ALboolean ALflangerState_deviceUpdate(ALflangerState *state, ALCdevice *D return AL_TRUE; } -static ALvoid ALflangerState_update(ALflangerState *state, ALCdevice *Device, const ALeffectslot *Slot) +static ALvoid ALflangerState_update(ALflangerState *state, const ALCdevice *Device, const ALeffectslot *Slot) { - static const ALfloat left_dir[3] = { -1.0f, 0.0f, 0.0f }; - static const ALfloat right_dir[3] = { 1.0f, 0.0f, 0.0f }; ALfloat frequency = (ALfloat)Device->Frequency; + ALfloat coeffs[MAX_AMBI_COEFFS]; ALfloat rate; ALint phase; @@ -113,8 +112,10 @@ static ALvoid ALflangerState_update(ALflangerState *state, ALCdevice *Device, co state->delay = fastf2i(Slot->EffectProps.Flanger.Delay * frequency); /* Gains for left and right sides */ - ComputeDirectionalGains(Device, left_dir, Slot->Gain, state->Gain[0]); - ComputeDirectionalGains(Device, right_dir, Slot->Gain, state->Gain[1]); + CalcXYZCoeffs(-1.0f, 0.0f, 0.0f, coeffs); + ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, Slot->Gain, state->Gain[0]); + CalcXYZCoeffs( 1.0f, 0.0f, 0.0f, coeffs); + ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, Slot->Gain, state->Gain[1]); phase = Slot->EffectProps.Flanger.Phase; rate = Slot->EffectProps.Flanger.Rate; diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.c index 32d25c76..9ef5d0dc 100644 --- a/Alc/effects/modulator.c +++ b/Alc/effects/modulator.c @@ -123,7 +123,7 @@ static ALboolean ALmodulatorState_deviceUpdate(ALmodulatorState *UNUSED(state), return AL_TRUE; } -static ALvoid ALmodulatorState_update(ALmodulatorState *state, ALCdevice *Device, const ALeffectslot *Slot) +static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCdevice *Device, const ALeffectslot *Slot) { ALfloat cw, a; @@ -148,7 +148,7 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, ALCdevice *Device state->Filter.b2 = 0.0f; state->Filter.input_gain = a; - ComputeAmbientGains(Device, Slot->Gain, state->Gain); + ComputeAmbientGains(Device->AmbiCoeffs, Device->NumChannels, Slot->Gain, state->Gain); } static ALvoid ALmodulatorState_process(ALmodulatorState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/Alc/effects/null.c b/Alc/effects/null.c index adc4ca81..d5f5bf11 100644 --- a/Alc/effects/null.c +++ b/Alc/effects/null.c @@ -33,7 +33,7 @@ static ALboolean ALnullState_deviceUpdate(ALnullState* UNUSED(state), ALCdevice* /* This updates the effect state. This is called any time the effect is * (re)loaded into a slot. */ -static ALvoid ALnullState_update(ALnullState* UNUSED(state), ALCdevice* UNUSED(device), const ALeffectslot* UNUSED(slot)) +static ALvoid ALnullState_update(ALnullState* UNUSED(state), const ALCdevice* UNUSED(device), const ALeffectslot* UNUSED(slot)) { } diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c index e1013309..f3de2116 100644 --- a/Alc/effects/reverb.c +++ b/Alc/effects/reverb.c @@ -1065,6 +1065,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection }, LatePanAngles[4] = { DEG2RAD(45.0f), DEG2RAD(-45.0f), DEG2RAD(135.0f), DEG2RAD(-135.0f) }; + ALfloat coeffs[MAX_AMBI_COEFFS]; ALfloat length, ev, az; ALuint i; @@ -1072,7 +1073,10 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection if(!(length > FLT_EPSILON)) { for(i = 0;i < 4;i++) - ComputeAngleGains(Device, EarlyPanAngles[i], 0.0f, Gain, State->Early.PanGain[i]); + { + CalcAngleCoeffs(EarlyPanAngles[i], 0.0f, coeffs); + ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, Gain, State->Early.PanGain[i]); + } } else { @@ -1090,7 +1094,8 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection float offset, naz, nev; naz = EarlyPanAngles[i] + (modff((az-EarlyPanAngles[i])*length/F_TAU + 1.5f, &offset)-0.5f)*F_TAU; nev = (modff((ev )*length/F_TAU + 1.5f, &offset)-0.5f)*F_TAU; - ComputeAngleGains(Device, naz, nev, Gain, State->Early.PanGain[i]); + CalcAngleCoeffs(naz, nev, coeffs); + ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, Gain, State->Early.PanGain[i]); } } @@ -1098,7 +1103,10 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection if(!(length > FLT_EPSILON)) { for(i = 0;i < 4;i++) - ComputeAngleGains(Device, LatePanAngles[i], 0.0f, Gain, State->Late.PanGain[i]); + { + CalcAngleCoeffs(LatePanAngles[i], 0.0f, coeffs); + ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, Gain, State->Late.PanGain[i]); + } } else { @@ -1111,12 +1119,13 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection float offset, naz, nev; naz = LatePanAngles[i] + (modff((az-LatePanAngles[i])*length/F_TAU + 1.5f, &offset)-0.5f)*F_TAU; nev = (modff((ev )*length/F_TAU + 1.5f, &offset)-0.5f)*F_TAU; - ComputeAngleGains(Device, naz, nev, Gain, State->Late.PanGain[i]); + CalcAngleCoeffs(naz, nev, coeffs); + ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, Gain, State->Late.PanGain[i]); } } } -static ALvoid ALreverbState_update(ALreverbState *State, ALCdevice *Device, const ALeffectslot *Slot) +static ALvoid ALreverbState_update(ALreverbState *State, const ALCdevice *Device, const ALeffectslot *Slot) { const ALeffectProps *props = &Slot->EffectProps; ALuint frequency = Device->Frequency; |