diff options
author | Chris Robinson <[email protected]> | 2013-05-20 04:16:48 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2013-05-20 04:16:48 -0700 |
commit | 5b706f3bdc1a8c8f064a253b53b4e86f9d88da8d (patch) | |
tree | 611e350eb0fe6986423e7a0522b6a42af436187c /Alc/alcEcho.c | |
parent | 80459b13e45306958f9fa2087ef750f1e736818b (diff) |
Process 64 samples at a time for some effects
This should help with the non-interleaved samples of the output, and
allow skipping channels that don't contribute to the output.
Diffstat (limited to 'Alc/alcEcho.c')
-rw-r--r-- | Alc/alcEcho.c | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/Alc/alcEcho.c b/Alc/alcEcho.c index 1d06e68a..498ebbc7 100644 --- a/Alc/alcEcho.c +++ b/Alc/alcEcho.c @@ -133,25 +133,47 @@ static ALvoid EchoProcess(ALeffectState *effect, ALuint SamplesToDo, const ALflo const ALuint tap2 = state->Tap[1].delay; ALuint offset = state->Offset; ALfloat smp; + ALuint base; ALuint i, k; - for(i = 0;i < SamplesToDo;i++,offset++) + for(base = 0;base < SamplesToDo;) { - /* First tap */ - smp = state->SampleBuffer[(offset-tap1) & mask]; - for(k = 0;k < MaxChannels;k++) - SamplesOut[k][i] += smp * state->Gain[0][k]; + ALfloat temps[64][2]; + ALuint td = minu(SamplesToDo-base, 64); + + for(i = 0;i < td;i++) + { + /* First tap */ + temps[i][0] = state->SampleBuffer[(offset-tap1) & mask]; + /* Second tap */ + temps[i][1] = state->SampleBuffer[(offset-tap2) & mask]; + + // Apply damping and feedback gain to the second tap, and mix in the + // new sample + smp = lpFilter2P(&state->iirFilter, 0, temps[i][1]+SamplesIn[i]); + state->SampleBuffer[offset&mask] = smp * state->FeedGain; + } - /* Second tap */ - smp = state->SampleBuffer[(offset-tap2) & mask]; for(k = 0;k < MaxChannels;k++) - SamplesOut[k][i] += smp * state->Gain[1][k]; - - // Apply damping and feedback gain to the second tap, and mix in the - // new sample - smp = lpFilter2P(&state->iirFilter, 0, smp+SamplesIn[i]); - state->SampleBuffer[offset&mask] = smp * state->FeedGain; + { + ALfloat gain = state->Gain[0][k]; + if(gain > 0.00001f) + { + for(i = 0;i < td;i++) + SamplesOut[k][i+base] += temps[i][0] * gain; + } + + gain = state->Gain[1][k]; + if(gain > 0.00001f) + { + for(i = 0;i < td;i++) + SamplesOut[k][i+base] += temps[i][1] * gain; + } + } + + base += td; } + state->Offset = offset; } |