diff options
author | Chris Robinson <[email protected]> | 2016-04-14 21:50:36 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-04-14 21:50:36 -0700 |
commit | fb97822d8c3e8a3f712099a2ecfcf0ec5a43c32e (patch) | |
tree | f20de7c6ad6ecdcf79599ae05e870dd8ac61684d /Alc | |
parent | 21921cdaffbd6f66a8cdc452925ca407b830c406 (diff) |
Avoid unnecessary loops for setting up effect slot b-format buffer mixing
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALu.c | 24 | ||||
-rw-r--r-- | Alc/panning.c | 40 |
2 files changed, 40 insertions, 24 deletions
@@ -537,8 +537,8 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A for(c = 0;c < num_channels;c++) { const ALeffectslot *Slot = SendSlots[i]; - ComputeFirstOrderGains(Slot->AmbiCoeffs, Slot->NumChannels, matrix.m[c], - WetGain[i], voice->Send[i].Gains[c].Target); + ComputeFirstOrderGainsBF(Slot->ChanMap, Slot->NumChannels, matrix.m[c], + WetGain[i], voice->Send[i].Gains[c].Target); } } } @@ -579,8 +579,8 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A else { const ALeffectslot *Slot = SendSlots[i]; - ComputePanningGains(Slot->AmbiCoeffs, Slot->NumChannels, coeffs, - WetGain[i], voice->Send[i].Gains[c].Target); + ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, + WetGain[i], voice->Send[i].Gains[c].Target); } } } @@ -636,8 +636,8 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A else { const ALeffectslot *Slot = SendSlots[i]; - ComputePanningGains(Slot->AmbiCoeffs, Slot->NumChannels, coeffs, - WetGain[i], voice->Send[i].Gains[c].Target); + ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, + WetGain[i], voice->Send[i].Gains[c].Target); } } } @@ -697,8 +697,8 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A else { const ALeffectslot *Slot = SendSlots[i]; - ComputePanningGains(Slot->AmbiCoeffs, Slot->NumChannels, coeffs, - WetGain[i], voice->Send[i].Gains[c].Target); + ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, + WetGain[i], voice->Send[i].Gains[c].Target); } } } @@ -1136,8 +1136,8 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte else { const ALeffectslot *Slot = SendSlots[i]; - ComputePanningGains(Slot->AmbiCoeffs, Slot->NumChannels, coeffs, - WetGain[i], voice->Send[i].Gains[0].Target); + ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, + WetGain[i], voice->Send[i].Gains[0].Target); } } @@ -1198,8 +1198,8 @@ ALvoid CalcSourceParams(ALvoice *voice, const ALsource *ALSource, const ALCconte else { const ALeffectslot *Slot = SendSlots[i]; - ComputePanningGains(Slot->AmbiCoeffs, Slot->NumChannels, coeffs, - WetGain[i], voice->Send[i].Gains[0].Target); + ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, + WetGain[i], voice->Send[i].Gains[0].Target); } } diff --git a/Alc/panning.c b/Alc/panning.c index fb707b2e..9248bb86 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -179,6 +179,16 @@ void ComputePanningGains(const ChannelConfig *chancoeffs, ALuint numchans, const gains[i] = 0.0f; } +void ComputePanningGainsBF(const BFChannelConfig *chanmap, ALuint numchans, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]) +{ + ALuint i; + + for(i = 0;i < numchans;i++) + gains[i] = chanmap[i].Scale * coeffs[chanmap[i].Index] * ingain; + for(;i < MAX_OUTPUT_CHANNELS;i++) + gains[i] = 0.0f; +} + void ComputeFirstOrderGains(const ChannelConfig *chancoeffs, ALuint numchans, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]) { ALuint i, j; @@ -194,6 +204,16 @@ void ComputeFirstOrderGains(const ChannelConfig *chancoeffs, ALuint numchans, co gains[i] = 0.0f; } +void ComputeFirstOrderGainsBF(const BFChannelConfig *chanmap, ALuint numchans, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]) +{ + ALuint i; + + for(i = 0;i < numchans;i++) + gains[i] = chanmap[i].Scale * mtx[chanmap[i].Index] * ingain; + for(;i < MAX_OUTPUT_CHANNELS;i++) + gains[i] = 0.0f; +} + DECL_CONST static inline const char *GetLabelFromChannel(enum Channel channel) { @@ -936,19 +956,15 @@ no_hrtf: void aluInitEffectPanning(ALeffectslot *slot) { - static const ChannelMap FirstOrderN3D[4] = { - { Aux0, { 1.0f, 0.0f, 0.0f, 0.0f } }, - { Aux1, { 0.0f, 1.0f, 0.0f, 0.0f } }, - { Aux2, { 0.0f, 0.0f, 1.0f, 0.0f } }, - { Aux3, { 0.0f, 0.0f, 0.0f, 1.0f } }, - }; - static const enum Channel AmbiChannels[MAX_OUTPUT_CHANNELS] = { - Aux0, Aux1, Aux2, Aux3, InvalidChannel - }; + ALuint i; - memset(slot->AmbiCoeffs, 0, sizeof(slot->AmbiCoeffs)); + memset(slot->ChanMap, 0, sizeof(slot->ChanMap)); slot->NumChannels = 0; - SetChannelMap(AmbiChannels, slot->AmbiCoeffs, FirstOrderN3D, COUNTOF(FirstOrderN3D), - &slot->NumChannels, AL_FALSE); + for(i = 0;i < MAX_EFFECT_CHANNELS;i++) + { + slot->ChanMap[i].Scale = 1.0f; + slot->ChanMap[i].Index = i; + } + slot->NumChannels = i; } |