aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/effects/distortion.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2014-12-18 09:23:55 -0800
committerChris Robinson <[email protected]>2014-12-18 09:23:55 -0800
commitc3a36d9b1975df8136c80412cb5ebfde711608d8 (patch)
tree5d8389b13d81e33bc4dc9c4cb727a31d3e2fd5f3 /Alc/effects/distortion.c
parent9897fca79407f741c8151a9914b0127d349f4093 (diff)
Do up to 256 samples at a time with multi-step loops
Diffstat (limited to 'Alc/effects/distortion.c')
-rw-r--r--Alc/effects/distortion.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/Alc/effects/distortion.c b/Alc/effects/distortion.c
index 7098cdf9..22e05c70 100644
--- a/Alc/effects/distortion.c
+++ b/Alc/effects/distortion.c
@@ -87,7 +87,6 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, ALCdevice *Devi
static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
{
const ALfloat fc = state->edge_coeff;
- float oversample_buffer[64][4];
ALuint base;
ALuint it;
ALuint ot;
@@ -95,8 +94,8 @@ static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint Samples
for(base = 0;base < SamplesToDo;)
{
- ALfloat temps[64];
- ALuint td = minu(SamplesToDo-base, 64);
+ float oversample_buffer[64][4];
+ ALuint td = minu(64, SamplesToDo-base);
/* Perform 4x oversampling to avoid aliasing. */
/* Oversampling greatly improves distortion */
@@ -148,20 +147,19 @@ static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint Samples
smp = ALfilterState_processSingle(&state->bandpass, smp);
oversample_buffer[it][ot] = smp;
}
-
- /* Fourth step, final, do attenuation and perform decimation, */
- /* store only one sample out of 4. */
- temps[it] = oversample_buffer[it][0] * state->attenuation;
}
for(kt = 0;kt < NumChannels;kt++)
{
- ALfloat gain = state->Gain[kt];
+ /* Fourth step, final, do attenuation and perform decimation,
+ * store only one sample out of 4.
+ */
+ ALfloat gain = state->Gain[kt] * state->attenuation;
if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD))
continue;
for(it = 0;it < td;it++)
- SamplesOut[kt][base+it] += gain * temps[it];
+ SamplesOut[kt][base+it] += gain * oversample_buffer[it][0];
}
base += td;