diff options
-rw-r--r-- | Alc/ALu.c | 16 | ||||
-rw-r--r-- | Alc/bformatdec.c | 2 | ||||
-rw-r--r-- | Alc/effects/autowah.c | 4 | ||||
-rw-r--r-- | Alc/effects/chorus.c | 4 | ||||
-rw-r--r-- | Alc/effects/compressor.c | 3 | ||||
-rw-r--r-- | Alc/effects/dedicated.c | 2 | ||||
-rw-r--r-- | Alc/effects/distortion.c | 3 | ||||
-rw-r--r-- | Alc/effects/echo.c | 4 | ||||
-rw-r--r-- | Alc/effects/equalizer.c | 18 | ||||
-rw-r--r-- | Alc/effects/fshifter.c | 2 | ||||
-rw-r--r-- | Alc/effects/modulator.c | 4 | ||||
-rw-r--r-- | Alc/effects/pshifter.c | 2 | ||||
-rw-r--r-- | Alc/effects/reverb.c | 8 | ||||
-rw-r--r-- | Alc/panning.c | 3 | ||||
-rw-r--r-- | OpenAL32/Include/alAuxEffectSlot.h | 4 | ||||
-rw-r--r-- | OpenAL32/Include/alu.h | 22 |
16 files changed, 42 insertions, 59 deletions
@@ -656,7 +656,7 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALflo Elev, Spread, coeffs); /* NOTE: W needs to be scaled by sqrt(2) due to FuMa normalization. */ - ComputeDryPanGains(&Device->Dry, coeffs, DryGain*SQRTF_2, + ComputePanGains(&Device->Dry, coeffs, DryGain*SQRTF_2, voice->Direct.Params[0].Gains.Target); for(i = 0;i < NumSends;i++) { @@ -724,8 +724,8 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALflo voice->Direct.Buffer = Device->FOAOut.Buffer; voice->Direct.Channels = Device->FOAOut.NumChannels; for(c = 0;c < num_channels;c++) - ComputeFirstOrderGains(&Device->FOAOut, matrix.m[c], DryGain, - voice->Direct.Params[c].Gains.Target); + ComputePanGains(&Device->FOAOut, matrix.m[c], DryGain, + voice->Direct.Params[c].Gains.Target); for(i = 0;i < NumSends;i++) { const ALeffectslot *Slot = SendSlots[i]; @@ -911,9 +911,8 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALflo continue; } - ComputeDryPanGains(&Device->Dry, - coeffs, DryGain * downmix_gain, voice->Direct.Params[c].Gains.Target - ); + ComputePanGains(&Device->Dry, coeffs, DryGain * downmix_gain, + voice->Direct.Params[c].Gains.Target); } for(i = 0;i < NumSends;i++) @@ -974,9 +973,8 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALflo chans[c].elevation, Spread, coeffs ); - ComputeDryPanGains(&Device->Dry, - coeffs, DryGain, voice->Direct.Params[c].Gains.Target - ); + ComputePanGains(&Device->Dry, coeffs, DryGain, + voice->Direct.Params[c].Gains.Target); for(i = 0;i < NumSends;i++) { const ALeffectslot *Slot = SendSlots[i]; diff --git a/Alc/bformatdec.c b/Alc/bformatdec.c index 58898083..5233d06f 100644 --- a/Alc/bformatdec.c +++ b/Alc/bformatdec.c @@ -438,7 +438,7 @@ void ambiup_reset(struct AmbiUpsampler *ambiup, const ALCdevice *device, ALfloat { ALfloat coeffs[MAX_AMBI_COEFFS] = { 0.0f }; CalcDirectionCoeffs(Ambi3DPoints[k], 0.0f, coeffs); - ComputeDryPanGains(&device->Dry, coeffs, 1.0f, encgains[k]); + ComputePanGains(&device->Dry, coeffs, 1.0f, encgains[k]); } /* Combine the matrices that do the in->virt and virt->out conversions diff --git a/Alc/effects/autowah.c b/Alc/effects/autowah.c index 28b366b1..ba1180ef 100644 --- a/Alc/effects/autowah.c +++ b/Alc/effects/autowah.c @@ -130,8 +130,8 @@ static ALvoid ALautowahState_update(ALautowahState *state, const ALCcontext *con 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, IdentityMatrixf.m[i], - slot->Params.Gain, state->Chans[i].TargetGains); + ComputePanGains(&device->FOAOut, IdentityMatrixf.m[i], slot->Params.Gain, + state->Chans[i].TargetGains); } static ALvoid ALautowahState_process(ALautowahState *state, ALsizei SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALsizei NumChannels) diff --git a/Alc/effects/chorus.c b/Alc/effects/chorus.c index ffb2b572..f2861cf5 100644 --- a/Alc/effects/chorus.c +++ b/Alc/effects/chorus.c @@ -149,9 +149,9 @@ static ALvoid ALchorusState_update(ALchorusState *state, const ALCcontext *Conte /* Gains for left and right sides */ CalcAngleCoeffs(-F_PI_2, 0.0f, 0.0f, coeffs); - ComputeDryPanGains(&device->Dry, coeffs, Slot->Params.Gain, state->Gains[0].Target); + ComputePanGains(&device->Dry, coeffs, Slot->Params.Gain, state->Gains[0].Target); CalcAngleCoeffs( F_PI_2, 0.0f, 0.0f, coeffs); - ComputeDryPanGains(&device->Dry, coeffs, Slot->Params.Gain, state->Gains[1].Target); + ComputePanGains(&device->Dry, coeffs, Slot->Params.Gain, state->Gains[1].Target); phase = props->Chorus.Phase; rate = props->Chorus.Rate; diff --git a/Alc/effects/compressor.c b/Alc/effects/compressor.c index af60777a..2b4a76b0 100644 --- a/Alc/effects/compressor.c +++ b/Alc/effects/compressor.c @@ -99,8 +99,7 @@ static ALvoid ALcompressorState_update(ALcompressorState *state, const ALCcontex 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, IdentityMatrixf.m[i], - slot->Params.Gain, state->Gain[i]); + ComputePanGains(&device->FOAOut, IdentityMatrixf.m[i], slot->Params.Gain, state->Gain[i]); } static ALvoid ALcompressorState_process(ALcompressorState *state, ALsizei SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALsizei NumChannels) diff --git a/Alc/effects/dedicated.c b/Alc/effects/dedicated.c index 62a3894f..0e1fd389 100644 --- a/Alc/effects/dedicated.c +++ b/Alc/effects/dedicated.c @@ -102,7 +102,7 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCcontext STATIC_CAST(ALeffectState,state)->OutBuffer = device->Dry.Buffer; STATIC_CAST(ALeffectState,state)->OutChannels = device->Dry.NumChannels; - ComputeDryPanGains(&device->Dry, coeffs, Gain, state->TargetGains); + ComputePanGains(&device->Dry, coeffs, Gain, state->TargetGains); } } } diff --git a/Alc/effects/distortion.c b/Alc/effects/distortion.c index f4e9969c..de8da4fe 100644 --- a/Alc/effects/distortion.c +++ b/Alc/effects/distortion.c @@ -104,8 +104,7 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, const ALCcontex ); CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs); - ComputeDryPanGains(&device->Dry, coeffs, slot->Params.Gain * props->Distortion.Gain, - state->Gain); + ComputePanGains(&device->Dry, coeffs, slot->Params.Gain*props->Distortion.Gain, state->Gain); } static ALvoid ALdistortionState_process(ALdistortionState *state, ALsizei SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALsizei NumChannels) diff --git a/Alc/effects/echo.c b/Alc/effects/echo.c index 676b17e8..4570fcb1 100644 --- a/Alc/effects/echo.c +++ b/Alc/effects/echo.c @@ -141,11 +141,11 @@ static ALvoid ALechoState_update(ALechoState *state, const ALCcontext *context, /* First tap panning */ CalcAngleCoeffs(-F_PI_2*lrpan, 0.0f, spread, coeffs); - ComputeDryPanGains(&device->Dry, coeffs, slot->Params.Gain, state->Gains[0].Target); + ComputePanGains(&device->Dry, coeffs, slot->Params.Gain, state->Gains[0].Target); /* Second tap panning */ CalcAngleCoeffs( F_PI_2*lrpan, 0.0f, spread, coeffs); - ComputeDryPanGains(&device->Dry, coeffs, slot->Params.Gain, state->Gains[1].Target); + ComputePanGains(&device->Dry, coeffs, slot->Params.Gain, state->Gains[1].Target); } static ALvoid ALechoState_process(ALechoState *state, ALsizei SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALsizei NumChannels) diff --git a/Alc/effects/equalizer.c b/Alc/effects/equalizer.c index 8ff56fb5..17106127 100644 --- a/Alc/effects/equalizer.c +++ b/Alc/effects/equalizer.c @@ -76,12 +76,12 @@ typedef struct ALequalizerState { DERIVE_FROM_TYPE(ALeffectState); struct { + /* Effect parameters */ + BiquadFilter filter[4]; + /* Effect gains for each channel */ ALfloat CurrentGains[MAX_OUTPUT_CHANNELS]; ALfloat TargetGains[MAX_OUTPUT_CHANNELS]; - - /* Effect parameters */ - BiquadFilter filter[4]; } Chans[MAX_EFFECT_CHANNELS]; ALfloat SampleBuffer[MAX_EFFECT_CHANNELS][BUFFERSIZE]; @@ -128,12 +128,6 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCcontext ALfloat gain, f0norm; ALuint i; - 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, IdentityMatrixf.m[i], - slot->Params.Gain, state->Chans[i].TargetGains); - /* Calculate coefficients for the each type of filter. Note that the shelf * filters' gain is for the reference frequency, which is the centerpoint * of the transition band. @@ -174,6 +168,12 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCcontext BiquadFilter_copyParams(&state->Chans[i].filter[2], &state->Chans[0].filter[2]); BiquadFilter_copyParams(&state->Chans[i].filter[3], &state->Chans[0].filter[3]); } + + STATIC_CAST(ALeffectState,state)->OutBuffer = device->FOAOut.Buffer; + STATIC_CAST(ALeffectState,state)->OutChannels = device->FOAOut.NumChannels; + for(i = 0;i < MAX_EFFECT_CHANNELS;i++) + ComputePanGains(&device->FOAOut, IdentityMatrixf.m[i], slot->Params.Gain, + state->Chans[i].TargetGains); } static ALvoid ALequalizerState_process(ALequalizerState *state, ALsizei SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALsizei NumChannels) diff --git a/Alc/effects/fshifter.c b/Alc/effects/fshifter.c index 5aa08453..7d72472a 100644 --- a/Alc/effects/fshifter.c +++ b/Alc/effects/fshifter.c @@ -144,7 +144,7 @@ static ALvoid ALfshifterState_update(ALfshifterState *state, const ALCcontext *c } CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs); - ComputeDryPanGains(&device->Dry, coeffs, slot->Params.Gain, state->TargetGains); + ComputePanGains(&device->Dry, coeffs, slot->Params.Gain, state->TargetGains); } static ALvoid ALfshifterState_process(ALfshifterState *state, ALsizei SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALsizei NumChannels) diff --git a/Alc/effects/modulator.c b/Alc/effects/modulator.c index 9855b1b8..e368adb8 100644 --- a/Alc/effects/modulator.c +++ b/Alc/effects/modulator.c @@ -158,8 +158,8 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCcontext 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, IdentityMatrixf.m[i], - slot->Params.Gain, state->Chans[i].TargetGains); + ComputePanGains(&device->FOAOut, IdentityMatrixf.m[i], slot->Params.Gain, + state->Chans[i].TargetGains); } static ALvoid ALmodulatorState_process(ALmodulatorState *state, ALsizei SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALsizei NumChannels) diff --git a/Alc/effects/pshifter.c b/Alc/effects/pshifter.c index f27c413c..ed18e9a8 100644 --- a/Alc/effects/pshifter.c +++ b/Alc/effects/pshifter.c @@ -208,7 +208,7 @@ static ALvoid ALpshifterState_update(ALpshifterState *state, const ALCcontext *c state->PitchShift = state->PitchShiftI * (1.0f/FRACTIONONE); CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs); - ComputeDryPanGains(&device->Dry, coeffs, slot->Params.Gain, state->TargetGains); + ComputePanGains(&device->Dry, coeffs, slot->Params.Gain, state->TargetGains); } static ALvoid ALpshifterState_process(ALpshifterState *state, ALsizei SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALsizei NumChannels) diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c index 6fdd53cd..a5de52f9 100644 --- a/Alc/effects/reverb.c +++ b/Alc/effects/reverb.c @@ -868,15 +868,15 @@ static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *Reflection MATRIX_MULT(transform, rot, A2B); memset(&State->Early.PanGain, 0, sizeof(State->Early.PanGain)); for(i = 0;i < MAX_EFFECT_CHANNELS;i++) - ComputeFirstOrderGains(&Device->FOAOut, transform.m[i], earlyGain, - State->Early.PanGain[i]); + ComputePanGains(&Device->FOAOut, transform.m[i], earlyGain, + State->Early.PanGain[i]); rot = GetTransformFromVector(LateReverbPan); MATRIX_MULT(transform, rot, A2B); memset(&State->Late.PanGain, 0, sizeof(State->Late.PanGain)); for(i = 0;i < MAX_EFFECT_CHANNELS;i++) - ComputeFirstOrderGains(&Device->FOAOut, transform.m[i], lateGain, - State->Late.PanGain[i]); + ComputePanGains(&Device->FOAOut, transform.m[i], lateGain, + State->Late.PanGain[i]); #undef MATRIX_MULT } diff --git a/Alc/panning.c b/Alc/panning.c index 0ddfd07e..2c0f3bf2 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -41,8 +41,7 @@ extern inline void CalcDirectionCoeffs(const ALfloat dir[3], ALfloat spread, ALfloat coeffs[MAX_AMBI_COEFFS]); extern inline void CalcAngleCoeffs(ALfloat azimuth, ALfloat elevation, ALfloat spread, ALfloat coeffs[MAX_AMBI_COEFFS]); extern inline float ScaleAzimuthFront(float azimuth, float scale); -extern inline void ComputeDryPanGains(const MixParams *dry, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]); -extern inline void ComputeFirstOrderGains(const MixParams *foa, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]); +extern inline void ComputePanGains(const MixParams *dry, const ALfloat*restrict coeffs, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]); static const ALsizei FuMa2ACN[MAX_AMBI_COEFFS] = { diff --git a/OpenAL32/Include/alAuxEffectSlot.h b/OpenAL32/Include/alAuxEffectSlot.h index c4d662f1..03ee97d6 100644 --- a/OpenAL32/Include/alAuxEffectSlot.h +++ b/OpenAL32/Include/alAuxEffectSlot.h @@ -145,8 +145,8 @@ typedef struct ALeffectslot { * * Channel 3 is OpenAL -Z * sqrt(3) * Consequently, effects that only want to work with mono input can use * channel 0 by itself. Effects that want multichannel can process the - * ambisonics signal and make a B-Format pan (ComputeFirstOrderGains) for - * first-order device output (FOAOut). + * ambisonics signal and make a B-Format source pan for first-order device + * output (FOAOut). */ alignas(16) ALfloat WetBuffer[MAX_EFFECT_CHANNELS][BUFFERSIZE]; } ALeffectslot; diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h index ac0c866f..c572fd71 100644 --- a/OpenAL32/Include/alu.h +++ b/OpenAL32/Include/alu.h @@ -495,12 +495,14 @@ void ComputePanningGainsMC(const ChannelConfig *chancoeffs, ALsizei numchans, AL void ComputePanningGainsBF(const BFChannelConfig *chanmap, ALsizei numchans, const ALfloat*restrict coeffs, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]); /** - * ComputeDryPanGains + * ComputePanGains * * Computes panning gains using the given channel decoder coefficients and the - * pre-calculated direction or angle coefficients. + * pre-calculated direction or angle coefficients. For B-Format sources, the + * coeffs are a 'slice' of a transform matrix for the input channel, used to + * scale and orient the sound samples. */ -inline void ComputeDryPanGains(const MixParams *dry, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]) +inline void ComputePanGains(const MixParams *dry, const ALfloat*restrict coeffs, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]) { if(dry->CoeffCount > 0) ComputePanningGainsMC(dry->Ambi.Coeffs, dry->NumChannels, dry->CoeffCount, @@ -508,20 +510,6 @@ inline void ComputeDryPanGains(const MixParams *dry, const ALfloat coeffs[MAX_AM else ComputePanningGainsBF(dry->Ambi.Map, dry->NumChannels, coeffs, ingain, gains); } -/** - * ComputeFirstOrderGains - * - * Sets channel gains for a first-order ambisonics input channel. The matrix is - * a 1x4 'slice' of a transform matrix for the input channel, used to scale and - * orient the sound samples. - */ -inline void ComputeFirstOrderGains(const MixParams *foa, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]) -{ - if(foa->CoeffCount > 0) - ComputePanningGainsMC(foa->Ambi.Coeffs, foa->NumChannels, 4, mtx, ingain, gains); - else - ComputePanningGainsBF(foa->Ambi.Map, foa->NumChannels, mtx, ingain, gains); -} ALboolean MixSource(struct ALvoice *voice, ALuint SourceID, ALCcontext *Context, ALsizei SamplesToDo); |