diff options
author | Chris Robinson <[email protected]> | 2016-04-15 22:05:47 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-04-15 22:05:47 -0700 |
commit | a6c70992b01b168d561c448fa235a86c9697b6ef (patch) | |
tree | c7fcc5d4d66e0f50a34e982abb954421c596c5d8 /Alc/effects | |
parent | e16032e1f0c92ff23c70393eccbac7def14d4bab (diff) |
More directly map coefficients for ambisonic mixing buffers
Instead of looping over all the coefficients for each channel with multiplies,
when we know only one will have a non-0 factor for ambisonic mixing buffers,
just index the one with a non-0 factor.
Diffstat (limited to 'Alc/effects')
-rw-r--r-- | Alc/effects/autowah.c | 2 | ||||
-rw-r--r-- | Alc/effects/chorus.c | 8 | ||||
-rw-r--r-- | Alc/effects/compressor.c | 4 | ||||
-rw-r--r-- | Alc/effects/dedicated.c | 11 | ||||
-rw-r--r-- | Alc/effects/distortion.c | 2 | ||||
-rw-r--r-- | Alc/effects/echo.c | 6 | ||||
-rw-r--r-- | Alc/effects/equalizer.c | 4 | ||||
-rw-r--r-- | Alc/effects/flanger.c | 8 | ||||
-rw-r--r-- | Alc/effects/modulator.c | 4 | ||||
-rw-r--r-- | Alc/effects/reverb.c | 21 |
10 files changed, 26 insertions, 44 deletions
diff --git a/Alc/effects/autowah.c b/Alc/effects/autowah.c index 20ae26e4..7c5abfb1 100644 --- a/Alc/effects/autowah.c +++ b/Alc/effects/autowah.c @@ -75,7 +75,7 @@ static ALvoid ALautowahState_update(ALautowahState *state, const ALCdevice *devi state->PeakGain = slot->EffectProps.Autowah.PeakGain; state->Resonance = slot->EffectProps.Autowah.Resonance; - ComputeAmbientGains(device->Dry.AmbiCoeffs, device->Dry.NumChannels, slot->Gain, state->Gain); + ComputeAmbientGains(device->Dry, slot->Gain, state->Gain); } static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/Alc/effects/chorus.c b/Alc/effects/chorus.c index a55983ab..94c9fc47 100644 --- a/Alc/effects/chorus.c +++ b/Alc/effects/chorus.c @@ -113,13 +113,9 @@ static ALvoid ALchorusState_update(ALchorusState *state, const ALCdevice *Device /* Gains for left and right sides */ CalcXYZCoeffs(-1.0f, 0.0f, 0.0f, coeffs); - ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, - Device->Dry.CoeffCount, coeffs, Slot->Gain, state->Gain[0] - ); + ComputePanningGains(Device->Dry, coeffs, Slot->Gain, state->Gain[0]); CalcXYZCoeffs( 1.0f, 0.0f, 0.0f, coeffs); - ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, - Device->Dry.CoeffCount, coeffs, Slot->Gain, state->Gain[1] - ); + ComputePanningGains(Device->Dry, 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 4e1d55f1..bc4955b9 100644 --- a/Alc/effects/compressor.c +++ b/Alc/effects/compressor.c @@ -72,8 +72,8 @@ static ALvoid ALcompressorState_update(ALcompressorState *state, const ALCdevice STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer; STATIC_CAST(ALeffectState,state)->OutChannels = device->FOAOut.NumChannels; for(i = 0;i < 4;i++) - ComputeFirstOrderGains(device->FOAOut.AmbiCoeffs, device->FOAOut.NumChannels, - matrix.m[i], slot->Gain, state->Gain[i]); + ComputeFirstOrderGains(device->FOAOut, matrix.m[i], slot->Gain, + state->Gain[i]); } static ALvoid ALcompressorState_process(ALcompressorState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/Alc/effects/dedicated.c b/Alc/effects/dedicated.c index 9fd10177..20acfdcf 100644 --- a/Alc/effects/dedicated.c +++ b/Alc/effects/dedicated.c @@ -59,9 +59,9 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCdevice * int idx; if((idx=GetChannelIdxByName(device->RealOut, LFE)) != -1) { - state->gains[idx] = Gain; STATIC_CAST(ALeffectState,state)->OutBuffer = device->RealOut.Buffer; STATIC_CAST(ALeffectState,state)->OutChannels = device->RealOut.NumChannels; + state->gains[idx] = Gain; } } else if(Slot->EffectType == AL_EFFECT_DEDICATED_DIALOGUE) @@ -71,23 +71,22 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCdevice * * plays from the front-center location. */ if((idx=GetChannelIdxByName(device->RealOut, FrontCenter)) != -1) { - state->gains[idx] = Gain; STATIC_CAST(ALeffectState,state)->OutBuffer = device->RealOut.Buffer; STATIC_CAST(ALeffectState,state)->OutChannels = device->RealOut.NumChannels; + state->gains[idx] = Gain; } else { + STATIC_CAST(ALeffectState,state)->OutBuffer = device->Dry.Buffer; + STATIC_CAST(ALeffectState,state)->OutChannels = device->Dry.NumChannels; if((idx=GetChannelIdxByName(device->Dry, FrontCenter)) != -1) state->gains[idx] = Gain; else { ALfloat coeffs[MAX_AMBI_COEFFS]; CalcXYZCoeffs(0.0f, 0.0f, -1.0f, coeffs); - ComputePanningGains(device->Dry.AmbiCoeffs, device->Dry.NumChannels, - device->Dry.CoeffCount, coeffs, Gain, state->gains); + ComputePanningGains(device->Dry, coeffs, Gain, state->gains); } - STATIC_CAST(ALeffectState,state)->OutBuffer = device->Dry.Buffer; - STATIC_CAST(ALeffectState,state)->OutChannels = device->Dry.NumChannels; } } } diff --git a/Alc/effects/distortion.c b/Alc/effects/distortion.c index 92eb1a6d..7a4c2f62 100644 --- a/Alc/effects/distortion.c +++ b/Alc/effects/distortion.c @@ -83,7 +83,7 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, const ALCdevice cutoff / (frequency*4.0f), calc_rcpQ_from_bandwidth(cutoff / (frequency*4.0f), bandwidth) ); - ComputeAmbientGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, Slot->Gain, state->Gain); + ComputeAmbientGains(Device->Dry, Slot->Gain, state->Gain); } static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/Alc/effects/echo.c b/Alc/effects/echo.c index 00bf5d9f..9fd31864 100644 --- a/Alc/effects/echo.c +++ b/Alc/effects/echo.c @@ -104,13 +104,11 @@ static ALvoid ALechoState_update(ALechoState *state, const ALCdevice *Device, co /* First tap panning */ CalcXYZCoeffs(-lrpan, 0.0f, 0.0f, coeffs); - ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, - Device->Dry.CoeffCount, coeffs, gain, state->Gain[0]); + ComputePanningGains(Device->Dry, coeffs, gain, state->Gain[0]); /* Second tap panning */ CalcXYZCoeffs( lrpan, 0.0f, 0.0f, coeffs); - ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, - Device->Dry.CoeffCount, coeffs, gain, state->Gain[1]); + ComputePanningGains(Device->Dry, coeffs, gain, state->Gain[1]); } static ALvoid ALechoState_process(ALechoState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c index f3383bd2..e0fa010e 100644 --- a/Alc/effects/equalizer.c +++ b/Alc/effects/equalizer.c @@ -113,8 +113,8 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice * STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer; STATIC_CAST(ALeffectState,state)->OutChannels = device->FOAOut.NumChannels; for(i = 0;i < MAX_EFFECT_CHANNELS;i++) - ComputeFirstOrderGains(device->FOAOut.AmbiCoeffs, device->FOAOut.NumChannels, - matrix.m[i], slot->Gain, state->Gain[i]); + ComputeFirstOrderGains(device->FOAOut, matrix.m[i], slot->Gain, + state->Gain[i]); /* 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 c323c17a..e394f9f2 100644 --- a/Alc/effects/flanger.c +++ b/Alc/effects/flanger.c @@ -113,13 +113,9 @@ static ALvoid ALflangerState_update(ALflangerState *state, const ALCdevice *Devi /* Gains for left and right sides */ CalcXYZCoeffs(-1.0f, 0.0f, 0.0f, coeffs); - ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, - Device->Dry.CoeffCount, coeffs, Slot->Gain, state->Gain[0] - ); + ComputePanningGains(Device->Dry, coeffs, Slot->Gain, state->Gain[0]); CalcXYZCoeffs( 1.0f, 0.0f, 0.0f, coeffs); - ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, - Device->Dry.CoeffCount, coeffs, Slot->Gain, state->Gain[1] - ); + ComputePanningGains(Device->Dry, 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 03e0d458..fb75043a 100644 --- a/Alc/effects/modulator.c +++ b/Alc/effects/modulator.c @@ -132,8 +132,8 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCdevice * STATIC_CAST(ALeffectState,state)->OutBuffer = Device->FOAOut.Buffer; STATIC_CAST(ALeffectState,state)->OutChannels = Device->FOAOut.NumChannels; for(i = 0;i < MAX_EFFECT_CHANNELS;i++) - ComputeFirstOrderGains(Device->FOAOut.AmbiCoeffs, Device->FOAOut.NumChannels, - matrix.m[i], Slot->Gain, state->Gain[i]); + ComputeFirstOrderGains(Device->FOAOut, matrix.m[i], Slot->Gain, + state->Gain[i]); } static ALvoid ALmodulatorState_process(ALmodulatorState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c index e5c19d82..bb980ac2 100644 --- a/Alc/effects/reverb.c +++ b/Alc/effects/reverb.c @@ -720,8 +720,7 @@ static ALvoid UpdateMixedPanning(const ALCdevice *Device, const ALfloat *Reflect length = minf(length, 1.0f); CalcDirectionCoeffs(pan, coeffs); - ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, - Device->Dry.CoeffCount, coeffs, Gain, DirGains); + ComputePanningGains(Device->Dry, coeffs, Gain, DirGains); for(i = 0;i < Device->Dry.NumChannels;i++) State->Early.PanGain[3][i] = DirGains[i] * EarlyGain * length; for(i = 0;i < Device->RealOut.NumChannels;i++) @@ -745,8 +744,7 @@ static ALvoid UpdateMixedPanning(const ALCdevice *Device, const ALfloat *Reflect length = minf(length, 1.0f); CalcDirectionCoeffs(pan, coeffs); - ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, - Device->Dry.CoeffCount, coeffs, Gain, DirGains); + ComputePanningGains(Device->Dry, coeffs, Gain, DirGains); for(i = 0;i < Device->Dry.NumChannels;i++) State->Late.PanGain[3][i] = DirGains[i] * LateGain * length; for(i = 0;i < Device->RealOut.NumChannels;i++) @@ -763,8 +761,7 @@ static ALvoid UpdateDirectPanning(const ALCdevice *Device, const ALfloat *Reflec ALuint i; /* Apply a boost of about 3dB to better match the expected stereo output volume. */ - ComputeAmbientGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, - Gain*1.414213562f, AmbientGains); + ComputeAmbientGains(Device->Dry, Gain*1.414213562f, AmbientGains); memset(State->Early.PanGain, 0, sizeof(State->Early.PanGain)); length = sqrtf(ReflectionsPan[0]*ReflectionsPan[0] + ReflectionsPan[1]*ReflectionsPan[1] + ReflectionsPan[2]*ReflectionsPan[2]); @@ -787,8 +784,7 @@ static ALvoid UpdateDirectPanning(const ALCdevice *Device, const ALfloat *Reflec length = minf(length, 1.0f); CalcDirectionCoeffs(pan, coeffs); - ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, - Device->Dry.CoeffCount, coeffs, Gain, DirGains); + ComputePanningGains(Device->Dry, coeffs, Gain, DirGains); for(i = 0;i < Device->Dry.NumChannels;i++) State->Early.PanGain[i&3][i] = lerp(AmbientGains[i], DirGains[i], length) * EarlyGain; } @@ -810,8 +806,7 @@ static ALvoid UpdateDirectPanning(const ALCdevice *Device, const ALfloat *Reflec length = minf(length, 1.0f); CalcDirectionCoeffs(pan, coeffs); - ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, - Device->Dry.CoeffCount, coeffs, Gain, DirGains); + ComputePanningGains(Device->Dry, coeffs, Gain, DirGains); for(i = 0;i < Device->Dry.NumChannels;i++) State->Late.PanGain[i&3][i] = lerp(AmbientGains[i], DirGains[i], length) * LateGain; } @@ -861,8 +856,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection for(i = 0;i < 4;i++) { CalcDirectionCoeffs(PanDirs[i], coeffs); - ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, - Device->Dry.CoeffCount, coeffs, Gain*EarlyGain*gain[i], + ComputePanningGains(Device->Dry, coeffs, Gain*EarlyGain*gain[i], State->Early.PanGain[i]); } @@ -893,8 +887,7 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection for(i = 0;i < 4;i++) { CalcDirectionCoeffs(PanDirs[i], coeffs); - ComputePanningGains(Device->Dry.AmbiCoeffs, Device->Dry.NumChannels, - Device->Dry.CoeffCount, coeffs, Gain*LateGain*gain[i], + ComputePanningGains(Device->Dry, coeffs, Gain*LateGain*gain[i], State->Late.PanGain[i]); } } |