diff options
author | Chris Robinson <[email protected]> | 2011-05-17 12:49:26 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-05-17 12:49:26 -0700 |
commit | 9f91ff4734259259290f7fcf0248ad0147c4ce1a (patch) | |
tree | 316fb180ff010cf8c638b034c4169cc164119574 | |
parent | f7936b47091fc4effa92ea4a67c9624c64305e80 (diff) |
Move the channel loop to the outside of the sample mixing loop
-rw-r--r-- | Alc/mixer.c | 128 |
1 files changed, 53 insertions, 75 deletions
diff --git a/Alc/mixer.c b/Alc/mixer.c index c0f79bd0..b13d991b 100644 --- a/Alc/mixer.c +++ b/Alc/mixer.c @@ -100,12 +100,12 @@ static void Mix_Hrtf_##T##_##chnct##_##sampler( \ HrtfHistory = Source->HrtfHistory; \ HrtfOffset = Source->HrtfOffset + OutPos; \ \ - pos = 0; \ - frac = *DataPosFrac; \ - \ - if(LIKELY(OutPos == 0)) \ + for(i = 0;i < chnct;i++) \ { \ - for(i = 0;i < chnct;i++) \ + pos = 0; \ + frac = *DataPosFrac; \ + \ + if(LIKELY(OutPos == 0)) \ { \ value = sampler(data + pos*chnct + i, chnct, frac); \ value = lpFilter2PC(DryFilter, i*2, value); \ @@ -121,10 +121,7 @@ static void Mix_Hrtf_##T##_##chnct##_##sampler( \ HrtfCoeffs[i][c][1]; \ } \ } \ - } \ - for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ - { \ - for(i = 0;i < chnct;i++) \ + for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ { \ value = sampler(data + pos*chnct + i, chnct, frac); \ value = lpFilter2P(DryFilter, i*2, value); \ @@ -139,17 +136,14 @@ static void Mix_Hrtf_##T##_##chnct##_##sampler( \ HrtfHistory[i][(HrtfOffset-c)&HRTF_LENGTH_MASK] * \ HrtfCoeffs[i][c][1]; \ } \ - } \ - HrtfOffset++; \ + HrtfOffset++; \ \ - frac += increment; \ - pos += frac>>FRACTIONBITS; \ - frac &= FRACTIONMASK; \ - OutPos++; \ - } \ - if(LIKELY(OutPos == SamplesToDo)) \ - { \ - for(i = 0;i < chnct;i++) \ + frac += increment; \ + pos += frac>>FRACTIONBITS; \ + frac &= FRACTIONMASK; \ + OutPos++; \ + } \ + if(LIKELY(OutPos == SamplesToDo)) \ { \ value = sampler(data + pos*chnct + i, chnct, frac); \ value = lpFilter2PC(DryFilter, i*2, value); \ @@ -165,6 +159,7 @@ static void Mix_Hrtf_##T##_##chnct##_##sampler( \ HrtfCoeffs[i][c][1]; \ } \ } \ + OutPos -= BufferSize; \ } \ \ for(out = 0;out < Device->NumAuxSends;out++) \ @@ -185,44 +180,38 @@ static void Mix_Hrtf_##T##_##chnct##_##sampler( \ WetFilter = &Source->Params.Send[out].iirFilter; \ WetSend = Source->Params.Send[out].WetGain; \ \ - pos = 0; \ - frac = *DataPosFrac; \ - OutPos -= BufferSize; \ - \ - if(LIKELY(OutPos == 0)) \ + for(i = 0;i < chnct;i++) \ { \ - for(i = 0;i < chnct;i++) \ + pos = 0; \ + frac = *DataPosFrac; \ + \ + if(LIKELY(OutPos == 0)) \ { \ value = sampler(data + pos*chnct + i, chnct, frac); \ value = lpFilter1PC(WetFilter, i, value); \ \ WetClickRemoval[0] -= value*WetSend * scaler; \ } \ - } \ - for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ - { \ - for(i = 0;i < chnct;i++) \ + for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ { \ value = sampler(data + pos*chnct + i, chnct, frac); \ value = lpFilter1P(WetFilter, i, value); \ \ WetBuffer[OutPos] += value*WetSend * scaler; \ - } \ \ - frac += increment; \ - pos += frac>>FRACTIONBITS; \ - frac &= FRACTIONMASK; \ - OutPos++; \ - } \ - if(LIKELY(OutPos == SamplesToDo)) \ - { \ - for(i = 0;i < chnct;i++) \ + frac += increment; \ + pos += frac>>FRACTIONBITS; \ + frac &= FRACTIONMASK; \ + OutPos++; \ + } \ + if(LIKELY(OutPos == SamplesToDo)) \ { \ value = sampler(data + pos*chnct + i, chnct, frac); \ value = lpFilter1PC(WetFilter, i, value); \ \ WetPendingClicks[0] += value*WetSend * scaler; \ } \ + OutPos -= BufferSize; \ } \ } \ *DataPosInt += pos; \ @@ -338,12 +327,12 @@ static void Mix_##T##_##chnct##_##sampler(ALsource *Source, ALCdevice *Device,\ DrySend[i][c] = Source->Params.DryGains[i][c]; \ } \ \ - pos = 0; \ - frac = *DataPosFrac; \ - \ - if(OutPos == 0) \ + for(i = 0;i < chnct;i++) \ { \ - for(i = 0;i < chnct;i++) \ + pos = 0; \ + frac = *DataPosFrac; \ + \ + if(OutPos == 0) \ { \ value = sampler(data + pos*chnct + i, chnct, frac); \ \ @@ -351,26 +340,20 @@ static void Mix_##T##_##chnct##_##sampler(ALsource *Source, ALCdevice *Device,\ for(c = 0;c < MAXCHANNELS;c++) \ ClickRemoval[c] -= value*DrySend[i][c]; \ } \ - } \ - for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ - { \ - for(i = 0;i < chnct;i++) \ + for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ { \ value = sampler(data + pos*chnct + i, chnct, frac); \ \ value = lpFilter2P(DryFilter, i*2, value); \ for(c = 0;c < MAXCHANNELS;c++) \ DryBuffer[OutPos][c] += value*DrySend[i][c]; \ - } \ \ - frac += increment; \ - pos += frac>>FRACTIONBITS; \ - frac &= FRACTIONMASK; \ - OutPos++; \ - } \ - if(OutPos == SamplesToDo) \ - { \ - for(i = 0;i < chnct;i++) \ + frac += increment; \ + pos += frac>>FRACTIONBITS; \ + frac &= FRACTIONMASK; \ + OutPos++; \ + } \ + if(OutPos == SamplesToDo) \ { \ value = sampler(data + pos*chnct + i, chnct, frac); \ \ @@ -378,6 +361,7 @@ static void Mix_##T##_##chnct##_##sampler(ALsource *Source, ALCdevice *Device,\ for(c = 0;c < MAXCHANNELS;c++) \ PendingClicks[c] += value*DrySend[i][c]; \ } \ + OutPos -= BufferSize; \ } \ \ for(out = 0;out < Device->NumAuxSends;out++) \ @@ -398,44 +382,38 @@ static void Mix_##T##_##chnct##_##sampler(ALsource *Source, ALCdevice *Device,\ WetFilter = &Source->Params.Send[out].iirFilter; \ WetSend = Source->Params.Send[out].WetGain; \ \ - pos = 0; \ - frac = *DataPosFrac; \ - OutPos -= BufferSize; \ - \ - if(OutPos == 0) \ + for(i = 0;i < chnct;i++) \ { \ - for(i = 0;i < chnct;i++) \ + pos = 0; \ + frac = *DataPosFrac; \ + \ + if(OutPos == 0) \ { \ value = sampler(data + pos*chnct + i, chnct, frac); \ \ value = lpFilter1PC(WetFilter, i, value); \ WetClickRemoval[0] -= value*WetSend * scaler; \ } \ - } \ - for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ - { \ - for(i = 0;i < chnct;i++) \ + for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ { \ value = sampler(data + pos*chnct + i, chnct, frac); \ \ value = lpFilter1P(WetFilter, i, value); \ WetBuffer[OutPos] += value*WetSend * scaler; \ - } \ \ - frac += increment; \ - pos += frac>>FRACTIONBITS; \ - frac &= FRACTIONMASK; \ - OutPos++; \ - } \ - if(OutPos == SamplesToDo) \ - { \ - for(i = 0;i < chnct;i++) \ + frac += increment; \ + pos += frac>>FRACTIONBITS; \ + frac &= FRACTIONMASK; \ + OutPos++; \ + } \ + if(OutPos == SamplesToDo) \ { \ value = sampler(data + pos*chnct + i, chnct, frac); \ \ value = lpFilter1PC(WetFilter, i, value); \ WetPendingClicks[0] += value*WetSend * scaler; \ } \ + OutPos -= BufferSize; \ } \ } \ *DataPosInt += pos; \ |