diff options
author | Chris Robinson <[email protected]> | 2015-10-29 03:23:50 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2015-10-29 03:23:50 -0700 |
commit | c3d58947c3e0b395f36bae272cedcad8fcc2de7c (patch) | |
tree | 62c918ec88b2bd9fddfaddc1c38c1d0541ff2663 /Alc/effects | |
parent | 79ad54f0c3f5ffcbc4f6ec160470724098aeb64e (diff) |
Mix reverb to output in the inner loop
Diffstat (limited to 'Alc/effects')
-rw-r--r-- | Alc/effects/reverb.c | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c index 8408dc3d..fac639b8 100644 --- a/Alc/effects/reverb.c +++ b/Alc/effects/reverb.c @@ -163,9 +163,9 @@ typedef struct ALreverbState { // Late.PanGain) ALfloat *Gain; - /* Temporary storage used when processing, before deinterlacing. */ - ALfloat ReverbSamples[BUFFERSIZE][4]; - ALfloat EarlySamples[BUFFERSIZE][4]; + /* Temporary storage used when processing. */ + ALfloat ReverbSamples[MAX_UPDATE_SAMPLES][4]; + ALfloat EarlySamples[MAX_UPDATE_SAMPLES][4]; } ALreverbState; /* This is a user config option for modifying the overall output of the reverb @@ -321,10 +321,10 @@ static inline ALvoid EarlyReflection(ALreverbState *State, ALuint todo, ALfloat DelayLineIn(&State->Early.Delay[3], offset, f[3]); // Output the results of the junction for all four channels. - out[i][0] += State->Early.Gain * f[0]; - out[i][1] += State->Early.Gain * f[1]; - out[i][2] += State->Early.Gain * f[2]; - out[i][3] += State->Early.Gain * f[3]; + out[i][0] = State->Early.Gain * f[0]; + out[i][1] = State->Early.Gain * f[1]; + out[i][2] = State->Early.Gain * f[2]; + out[i][3] = State->Early.Gain * f[3]; } } @@ -553,6 +553,7 @@ static inline ALvoid EAXVerbPass(ALreverbState *State, ALuint todo, const ALfloa } // Calculate the late reverb from the decorrelator taps. + memset(late, 0, sizeof(*late)*todo); LateReverb(State, todo, late); // Calculate and mix in any echo. @@ -565,27 +566,27 @@ static inline ALvoid EAXVerbPass(ALreverbState *State, ALuint todo, const ALfloa static ALvoid ALreverbState_processStandard(ALreverbState *State, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels) { ALfloat (*restrict out)[4] = State->ReverbSamples; - ALuint index, c; + ALuint index, c, i; memset(out, 0, SamplesToDo*4*sizeof(ALfloat)); /* Process reverb for these samples. */ for(index = 0;index < SamplesToDo;) { - ALfloat todo = minu(SamplesToDo, MAX_UPDATE_SAMPLES); + ALuint todo = minu(SamplesToDo-index, MAX_UPDATE_SAMPLES); - VerbPass(State, todo, SamplesIn+index, out+index); - index += todo; - } + VerbPass(State, todo, &SamplesIn[index], out); - for(c = 0;c < NumChannels;c++) - { - ALfloat gain = State->Gain[c]; - if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD)) - continue; + for(c = 0;c < NumChannels;c++) + { + ALfloat gain = State->Gain[c]; + if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD)) + continue; + for(i = 0;i < todo;i++) + SamplesOut[c][index+i] += gain*out[i][c&3]; + } - for(index = 0;index < SamplesToDo;index++) - SamplesOut[c][index] += gain * out[index][c&3]; + index += todo; } } @@ -593,36 +594,33 @@ static ALvoid ALreverbState_processEax(ALreverbState *State, ALuint SamplesToDo, { ALfloat (*restrict early)[4] = State->EarlySamples; ALfloat (*restrict late)[4] = State->ReverbSamples; - ALuint index, c; - - memset(early, 0, SamplesToDo*4*sizeof(ALfloat)); - memset(late, 0, SamplesToDo*4*sizeof(ALfloat)); + ALuint index, c, i; + ALfloat gain; /* Process reverb for these samples. */ for(index = 0;index < SamplesToDo;) { - ALfloat todo = minu(SamplesToDo, MAX_UPDATE_SAMPLES); + ALuint todo = minu(SamplesToDo-index, MAX_UPDATE_SAMPLES); - EAXVerbPass(State, todo, SamplesIn+index, early+index, late+index); - index += todo; - } - - for(c = 0;c < NumChannels;c++) - { - ALfloat earlyGain, lateGain; + EAXVerbPass(State, todo, &SamplesIn[index], early, late); - earlyGain = State->Early.PanGain[c]; - if(fabsf(earlyGain) > GAIN_SILENCE_THRESHOLD) + for(c = 0;c < NumChannels;c++) { - for(index = 0;index < SamplesToDo;index++) - SamplesOut[c][index] += earlyGain*early[index][c&3]; - } - lateGain = State->Late.PanGain[c]; - if(fabsf(lateGain) > GAIN_SILENCE_THRESHOLD) - { - for(index = 0;index < SamplesToDo;index++) - SamplesOut[c][index] += lateGain*late[index][c&3]; + gain = State->Early.PanGain[c]; + if(fabsf(gain) > GAIN_SILENCE_THRESHOLD) + { + for(i = 0;i < todo;i++) + SamplesOut[c][index+i] += gain*early[i][c&3]; + } + gain = State->Late.PanGain[c]; + if(fabsf(gain) > GAIN_SILENCE_THRESHOLD) + { + for(i = 0;i < todo;i++) + SamplesOut[c][index+i] += gain*late[i][c&3]; + } } + + index += todo; } } |