diff options
author | Chris Robinson <[email protected]> | 2010-08-15 15:09:38 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2010-08-15 15:09:38 -0700 |
commit | 343a8241ab16e68ceeba69cf8eb95ed9e2519d71 (patch) | |
tree | ae1a3be731af88ee98605b195f0ed2a87b7a99fb /Alc/mixer.c | |
parent | 00525274a0d32b5958e82ac309ece9d9132332f1 (diff) |
Use a multiplier instead of if checks
Diffstat (limited to 'Alc/mixer.c')
-rw-r--r-- | Alc/mixer.c | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/Alc/mixer.c b/Alc/mixer.c index 99ecb9d1..04663850 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -239,7 +239,7 @@ static void MixSource(ALsource *ALSource, ALCcontext *ALContext, #define DO_MIX(resampler) do { \ if(j == 0 && UpdateClick) \ { \ - const ALboolean FirstStart = ALSource->FirstStart; \ + const ALfloat Starter = (ALSource->FirstStart ? 1.0f : 0.0f); \ \ value = (resampler)(Data[DataPosInt], Data[DataPosInt+1], \ DataPosFrac); \ @@ -252,24 +252,21 @@ static void MixSource(ALsource *ALSource, ALCcontext *ALContext, ClickRemoval[BACK_RIGHT] += outsamp*dryGainDiff[BACK_RIGHT]; \ ClickRemoval[FRONT_CENTER] += outsamp*dryGainDiff[FRONT_CENTER]; \ ClickRemoval[BACK_CENTER] += outsamp*dryGainDiff[BACK_CENTER]; \ - if(FirstStart) \ - { \ - ClickRemoval[FRONT_LEFT] += -outsamp*DrySend[FRONT_LEFT]; \ - ClickRemoval[FRONT_RIGHT] += -outsamp*DrySend[FRONT_RIGHT]; \ - ClickRemoval[SIDE_LEFT] += -outsamp*DrySend[SIDE_LEFT]; \ - ClickRemoval[SIDE_RIGHT] += -outsamp*DrySend[SIDE_RIGHT]; \ - ClickRemoval[BACK_LEFT] += -outsamp*DrySend[BACK_LEFT]; \ - ClickRemoval[BACK_RIGHT] += -outsamp*DrySend[BACK_RIGHT]; \ - ClickRemoval[FRONT_CENTER] += -outsamp*DrySend[FRONT_CENTER]; \ - ClickRemoval[BACK_CENTER] += -outsamp*DrySend[BACK_CENTER]; \ - } \ + \ + ClickRemoval[FRONT_LEFT] -= outsamp*Starter*DrySend[FRONT_LEFT]; \ + ClickRemoval[FRONT_RIGHT] -= outsamp*Starter*DrySend[FRONT_RIGHT]; \ + ClickRemoval[SIDE_LEFT] -= outsamp*Starter*DrySend[SIDE_LEFT]; \ + ClickRemoval[SIDE_RIGHT] -= outsamp*Starter*DrySend[SIDE_RIGHT]; \ + ClickRemoval[BACK_LEFT] -= outsamp*Starter*DrySend[BACK_LEFT]; \ + ClickRemoval[BACK_RIGHT] -= outsamp*Starter*DrySend[BACK_RIGHT]; \ + ClickRemoval[FRONT_CENTER] -= outsamp*Starter*DrySend[FRONT_CENTER]; \ + ClickRemoval[BACK_CENTER] -= outsamp*Starter*DrySend[BACK_CENTER]; \ \ for(out = 0;out < MAX_SENDS;out++) \ { \ outsamp = lpFilter2PC(WetFilter[out], 0, value); \ WetClickRemoval[out][0] += outsamp*wetGainDiff[BACK_CENTER]; \ - if(FirstStart) \ - WetClickRemoval[out][0] += -outsamp*WetSend[out]; \ + WetClickRemoval[out][0] -= outsamp*Starter*WetSend[out]; \ } \ } \ while(BufferSize--) \ @@ -330,7 +327,7 @@ static void MixSource(ALsource *ALSource, ALCcontext *ALContext, const ALfloat scaler = 1.0f/Channels; \ if(j == 0 && UpdateClick) \ { \ - const ALboolean FirstStart = ALSource->FirstStart; \ + const ALfloat Starter = (ALSource->FirstStart ? 1.0f : 0.0f); \ for(i = 0;i < Channels;i++) \ { \ value = (resampler)(Data[DataPosInt*Channels + i], \ @@ -341,19 +338,16 @@ static void MixSource(ALsource *ALSource, ALCcontext *ALContext, ClickRemoval[chans[i]] += outsamp*dryGainDiff[chans[i]]; \ ClickRemoval[chans2[i*2+0]] += outsamp*dryGainDiff[chans2[i*2+0]];\ ClickRemoval[chans2[i*2+1]] += outsamp*dryGainDiff[chans2[i*2+1]];\ - if(FirstStart) \ - { \ - ClickRemoval[chans[i]] += -outsamp*DrySend[chans[i]]; \ - ClickRemoval[chans2[i*2+0]] += -outsamp*DrySend[chans2[i*2+0]];\ - ClickRemoval[chans2[i*2+1]] += -outsamp*DrySend[chans2[i*2+1]];\ - } \ + \ + ClickRemoval[chans[i]] -= outsamp*Starter*DrySend[chans[i]]; \ + ClickRemoval[chans2[i*2+0]] -= outsamp*Starter*DrySend[chans2[i*2+0]];\ + ClickRemoval[chans2[i*2+1]] -= outsamp*Starter*DrySend[chans2[i*2+1]];\ \ for(out = 0;out < MAX_SENDS;out++) \ { \ outsamp = lpFilter1PC(WetFilter[out], chans[out], value) * scaler;\ WetClickRemoval[out][0] += outsamp*wetGainDiff[out]; \ - if(FirstStart) \ - WetClickRemoval[out][0] += -outsamp*WetSend[out]; \ + WetClickRemoval[out][0] -= outsamp*Starter*WetSend[out]; \ } \ } \ } \ @@ -409,7 +403,7 @@ static void MixSource(ALsource *ALSource, ALCcontext *ALContext, const ALfloat scaler = 1.0f/Channels; \ if(j == 0 && UpdateClick) \ { \ - const ALboolean FirstStart = ALSource->FirstStart; \ + const ALfloat Starter = (ALSource->FirstStart ? 1.0f : 0.0f); \ for(i = 0;i < Channels;i++) \ { \ value = (resampler)(Data[DataPosInt*Channels + i], \ @@ -418,15 +412,13 @@ static void MixSource(ALsource *ALSource, ALCcontext *ALContext, \ outsamp = lpFilter2PC(DryFilter, chans[i]*2, value); \ ClickRemoval[chans[i]] += outsamp*dryGainDiff[chans[i]]; \ - if(FirstStart) \ - ClickRemoval[chans[i]] += -outsamp*DrySend[chans[i]]; \ + ClickRemoval[chans[i]] -= outsamp*Starter*DrySend[chans[i]]; \ \ for(out = 0;out < MAX_SENDS;out++) \ { \ outsamp = lpFilter1PC(WetFilter[out], chans[out], value) * scaler;\ WetClickRemoval[out][0] += outsamp*wetGainDiff[out]; \ - if(FirstStart) \ - WetClickRemoval[out][0] += -outsamp*WetSend[out]; \ + WetClickRemoval[out][0] -= outsamp*Starter*WetSend[out]; \ } \ } \ } \ |