From 5181e78c1ed098866df7b498de335fb25022f97e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 21 Feb 2017 18:28:09 -0800 Subject: Reduce some code --- Alc/ALu.c | 94 ++++++++++++++++++++++----------------------------------------- 1 file changed, 33 insertions(+), 61 deletions(-) (limited to 'Alc/ALu.c') diff --git a/Alc/ALu.c b/Alc/ALu.c index edb23128..503fde6c 100644 --- a/Alc/ALu.c +++ b/Alc/ALu.c @@ -541,23 +541,19 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps * for(i = 0;i < NumSends;i++) { - if(!SendSlots[i]) + const ALeffectslot *Slot = SendSlots[i]; + if(Slot) { for(c = 0;c < num_channels;c++) - { - for(j = 0;j < MAX_EFFECT_CHANNELS;j++) - voice->Send[i].Params[c].Gains.Target[j] = 0.0f; - } + ComputeFirstOrderGainsBF(Slot->ChanMap, Slot->NumChannels, + matrix.m[c], WetGain[i], voice->Send[i].Params[c].Gains.Target + ); } else { for(c = 0;c < num_channels;c++) - { - const ALeffectslot *Slot = SendSlots[i]; - ComputeFirstOrderGainsBF(Slot->ChanMap, Slot->NumChannels, - matrix.m[c], WetGain[i], voice->Send[i].Params[c].Gains.Target - ); - } + for(j = 0;j < MAX_EFFECT_CHANNELS;j++) + voice->Send[i].Params[c].Gains.Target[j] = 0.0f; } } @@ -589,18 +585,14 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps * for(i = 0;i < NumSends;i++) { - if(!SendSlots[i]) - { - for(j = 0;j < MAX_EFFECT_CHANNELS;j++) - voice->Send[i].Params[c].Gains.Target[j] = 0.0f; - } - else - { - const ALeffectslot *Slot = SendSlots[i]; + const ALeffectslot *Slot = SendSlots[i]; + if(Slot) ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, WetGain[i], voice->Send[i].Params[c].Gains.Target ); - } + else + for(j = 0;j < MAX_EFFECT_CHANNELS;j++) + voice->Send[i].Params[c].Gains.Target[j] = 0.0f; } } @@ -647,18 +639,14 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps * for(i = 0;i < NumSends;i++) { - if(!SendSlots[i]) - { - for(j = 0;j < MAX_EFFECT_CHANNELS;j++) - voice->Send[i].Params[c].Gains.Target[j] = 0.0f; - } - else - { - const ALeffectslot *Slot = SendSlots[i]; + const ALeffectslot *Slot = SendSlots[i]; + if(Slot) ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, WetGain[i], voice->Send[i].Params[c].Gains.Target ); - } + else + for(j = 0;j < MAX_EFFECT_CHANNELS;j++) + voice->Send[i].Params[c].Gains.Target[j] = 0.0f; } } @@ -683,7 +671,6 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps * for(i = 0;i < NumSends;i++) { - ALuint j; for(j = 0;j < MAX_EFFECT_CHANNELS;j++) voice->Direct.Params[c].Gains.Target[j] = 0.0f; } @@ -711,19 +698,14 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps * for(i = 0;i < NumSends;i++) { - if(!SendSlots[i]) - { - ALuint j; - for(j = 0;j < MAX_EFFECT_CHANNELS;j++) - voice->Send[i].Params[c].Gains.Target[j] = 0.0f; - } - else - { - const ALeffectslot *Slot = SendSlots[i]; + const ALeffectslot *Slot = SendSlots[i]; + if(Slot) ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, WetGain[i], voice->Send[i].Params[c].Gains.Target ); - } + else + for(j = 0;j < MAX_EFFECT_CHANNELS;j++) + voice->Send[i].Params[c].Gains.Target[j] = 0.0f; } } @@ -808,7 +790,7 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro ALfloat Pitch; ALuint Frequency; ALint NumSends; - ALint i; + ALint i, j; /* Get context/device properties */ DopplerFactor = Listener->Params.DopplerFactor; @@ -1159,19 +1141,14 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro for(i = 0;i < NumSends;i++) { - if(!SendSlots[i]) - { - ALuint j; - for(j = 0;j < MAX_EFFECT_CHANNELS;j++) - voice->Send[i].Params[0].Gains.Target[j] = 0.0f; - } - else - { - const ALeffectslot *Slot = SendSlots[i]; + const ALeffectslot *Slot = SendSlots[i]; + if(Slot) ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, WetGain[i], voice->Send[i].Params[0].Gains.Target ); - } + else + for(j = 0;j < MAX_EFFECT_CHANNELS;j++) + voice->Send[i].Params[0].Gains.Target[j] = 0.0f; } voice->IsHrtf = AL_TRUE; @@ -1217,19 +1194,14 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro for(i = 0;i < NumSends;i++) { - if(!SendSlots[i]) - { - ALuint j; - for(j = 0;j < MAX_EFFECT_CHANNELS;j++) - voice->Send[i].Params[0].Gains.Target[j] = 0.0f; - } - else - { - const ALeffectslot *Slot = SendSlots[i]; + const ALeffectslot *Slot = SendSlots[i]; + if(Slot) ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, WetGain[i], voice->Send[i].Params[0].Gains.Target ); - } + else + for(j = 0;j < MAX_EFFECT_CHANNELS;j++) + voice->Send[i].Params[0].Gains.Target[j] = 0.0f; } voice->IsHrtf = AL_FALSE; -- cgit v1.2.3