Pass a pointer to the input samples array for effect processing

This commit is contained in:
Chris Robinson 2016-01-27 08:16:47 -08:00
parent fd387beda1
commit 2fa3ae85c9
13 changed files with 44 additions and 38 deletions

View File

@ -1473,19 +1473,25 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
}
/* effect slot processing */
#define PROCESS_SLOT(iter) V((*iter)->EffectState,process)( \
SamplesToDo, (*iter)->WetBuffer[0], device->DryBuffer, device->NumChannels \
);
VECTOR_FOR_EACH(ALeffectslot*, ctx->ActiveAuxSlots, PROCESS_SLOT);
#undef PROCESS_SLOT
c = VECTOR_SIZE(ctx->ActiveAuxSlots);
for(i = 0;i < c;i++)
{
const ALeffectslot *slot = VECTOR_ELEM(ctx->ActiveAuxSlots, i);
ALeffectState *state = slot->EffectState;
V(state,process)(SamplesToDo, slot->WetBuffer, device->DryBuffer,
device->NumChannels);
}
ctx = ctx->next;
}
if((slot=device->DefaultSlot) != NULL)
V(slot->EffectState,process)(
SamplesToDo, slot->WetBuffer[0], device->DryBuffer, device->NumChannels
);
if(device->DefaultSlot != NULL)
{
const ALeffectslot *slot = device->DefaultSlot;
ALeffectState *state = slot->EffectState;
V(state,process)(SamplesToDo, slot->WetBuffer, device->DryBuffer,
device->NumChannels);
}
/* Increment the clock time. Every second's worth of samples is
* converted and added to clock base so that large sample counts don't

View File

@ -78,7 +78,7 @@ static ALvoid ALautowahState_update(ALautowahState *state, const ALCdevice *devi
ComputeAmbientGains(device->AmbiCoeffs, device->NumChannels, slot->Gain, state->Gain);
}
static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[BUFFERSIZE], ALuint NumChannels)
static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
{
ALuint it, kt;
ALuint base;
@ -91,7 +91,7 @@ static ALvoid ALautowahState_process(ALautowahState *state, ALuint SamplesToDo,
for(it = 0;it < td;it++)
{
ALfloat smp = SamplesIn[it+base];
ALfloat smp = SamplesIn[0][it+base];
ALfloat a[3], b[3];
ALfloat alpha, w0;
ALfloat amplitude;

View File

@ -204,7 +204,7 @@ DECL_TEMPLATE(Sinusoid)
#undef DECL_TEMPLATE
static ALvoid ALchorusState_process(ALchorusState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
static ALvoid ALchorusState_process(ALchorusState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
{
ALuint it, kt;
ALuint base;
@ -217,10 +217,10 @@ static ALvoid ALchorusState_process(ALchorusState *state, ALuint SamplesToDo, co
switch(state->waveform)
{
case CWF_Triangle:
ProcessTriangle(state, td, SamplesIn+base, temps);
ProcessTriangle(state, td, SamplesIn[0]+base, temps);
break;
case CWF_Sinusoid:
ProcessSinusoid(state, td, SamplesIn+base, temps);
ProcessSinusoid(state, td, SamplesIn[0]+base, temps);
break;
}

View File

@ -62,7 +62,7 @@ static ALvoid ALcompressorState_update(ALcompressorState *state, const ALCdevice
ComputeAmbientGains(device->AmbiCoeffs, device->NumChannels, slot->Gain, state->Gain);
}
static ALvoid ALcompressorState_process(ALcompressorState *state, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[BUFFERSIZE], ALuint NumChannels)
static ALvoid ALcompressorState_process(ALcompressorState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
{
ALuint it, kt;
ALuint base;
@ -79,7 +79,7 @@ static ALvoid ALcompressorState_process(ALcompressorState *state, ALuint Samples
for(it = 0;it < td;it++)
{
smp = SamplesIn[it+base];
smp = SamplesIn[0][it+base];
amplitude = fabsf(smp);
if(amplitude > gain)
@ -100,7 +100,7 @@ static ALvoid ALcompressorState_process(ALcompressorState *state, ALuint Samples
for(it = 0;it < td;it++)
{
smp = SamplesIn[it+base];
smp = SamplesIn[0][it+base];
amplitude = 1.0f;
if(amplitude > gain)

View File

@ -76,7 +76,7 @@ static ALvoid ALdedicatedState_update(ALdedicatedState *state, const ALCdevice *
}
}
static ALvoid ALdedicatedState_process(ALdedicatedState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
static ALvoid ALdedicatedState_process(ALdedicatedState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
{
const ALfloat *gains = state->gains;
ALuint i, c;
@ -87,7 +87,7 @@ static ALvoid ALdedicatedState_process(ALdedicatedState *state, ALuint SamplesTo
continue;
for(i = 0;i < SamplesToDo;i++)
SamplesOut[c][i] += SamplesIn[i] * gains[c];
SamplesOut[c][i] += SamplesIn[0][i] * gains[c];
}
}

View File

@ -86,7 +86,7 @@ static ALvoid ALdistortionState_update(ALdistortionState *state, const ALCdevice
ComputeAmbientGains(Device->AmbiCoeffs, Device->NumChannels, Slot->Gain, state->Gain);
}
static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
{
const ALfloat fc = state->edge_coeff;
ALuint base;
@ -108,7 +108,7 @@ static ALvoid ALdistortionState_process(ALdistortionState *state, ALuint Samples
/* Fill oversample buffer using zero stuffing */
for(it = 0;it < td;it++)
{
oversample_buffer[it][0] = SamplesIn[it+base];
oversample_buffer[it][0] = SamplesIn[0][it+base];
oversample_buffer[it][1] = 0.0f;
oversample_buffer[it][2] = 0.0f;
oversample_buffer[it][3] = 0.0f;

View File

@ -111,7 +111,7 @@ static ALvoid ALechoState_update(ALechoState *state, const ALCdevice *Device, co
ComputePanningGains(Device->AmbiCoeffs, Device->NumChannels, coeffs, gain, state->Gain[1]);
}
static ALvoid ALechoState_process(ALechoState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
static ALvoid ALechoState_process(ALechoState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
{
const ALuint mask = state->BufferLength-1;
const ALuint tap1 = state->Tap[0].delay;
@ -135,7 +135,7 @@ static ALvoid ALechoState_process(ALechoState *state, ALuint SamplesToDo, const
// Apply damping and feedback gain to the second tap, and mix in the
// new sample
smp = ALfilterState_processSingle(&state->Filter, temps[i][1]+SamplesIn[i+base]);
smp = ALfilterState_processSingle(&state->Filter, temps[i][1]+SamplesIn[0][i+base]);
state->SampleBuffer[offset&mask] = smp * state->FeedGain;
offset++;
}

View File

@ -126,7 +126,7 @@ static ALvoid ALequalizerState_update(ALequalizerState *state, const ALCdevice *
);
}
static ALvoid ALequalizerState_process(ALequalizerState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
static ALvoid ALequalizerState_process(ALequalizerState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
{
ALuint base;
ALuint it;
@ -140,7 +140,7 @@ static ALvoid ALequalizerState_process(ALequalizerState *state, ALuint SamplesTo
for(it = 0;it < td;it++)
{
ALfloat smp = SamplesIn[base+it];
ALfloat smp = SamplesIn[0][base+it];
for(ft = 0;ft < 4;ft++)
smp = ALfilterState_processSingle(&state->filter[ft], smp);

View File

@ -204,7 +204,7 @@ DECL_TEMPLATE(Sinusoid)
#undef DECL_TEMPLATE
static ALvoid ALflangerState_process(ALflangerState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
static ALvoid ALflangerState_process(ALflangerState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
{
ALuint it, kt;
ALuint base;
@ -217,10 +217,10 @@ static ALvoid ALflangerState_process(ALflangerState *state, ALuint SamplesToDo,
switch(state->waveform)
{
case FWF_Triangle:
ProcessTriangle(state, td, SamplesIn+base, temps);
ProcessTriangle(state, td, SamplesIn[0]+base, temps);
break;
case FWF_Sinusoid:
ProcessSinusoid(state, td, SamplesIn+base, temps);
ProcessSinusoid(state, td, SamplesIn[0]+base, temps);
break;
}

View File

@ -151,20 +151,20 @@ static ALvoid ALmodulatorState_update(ALmodulatorState *state, const ALCdevice *
ComputeAmbientGains(Device->AmbiCoeffs, Device->NumChannels, Slot->Gain, state->Gain);
}
static ALvoid ALmodulatorState_process(ALmodulatorState *state, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
static ALvoid ALmodulatorState_process(ALmodulatorState *state, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
{
switch(state->Waveform)
{
case SINUSOID:
ProcessSin(state, SamplesToDo, SamplesIn, SamplesOut, NumChannels);
ProcessSin(state, SamplesToDo, SamplesIn[0], SamplesOut, NumChannels);
break;
case SAWTOOTH:
ProcessSaw(state, SamplesToDo, SamplesIn, SamplesOut, NumChannels);
ProcessSaw(state, SamplesToDo, SamplesIn[0], SamplesOut, NumChannels);
break;
case SQUARE:
ProcessSquare(state, SamplesToDo, SamplesIn, SamplesOut, NumChannels);
ProcessSquare(state, SamplesToDo, SamplesIn[0], SamplesOut, NumChannels);
break;
}
}

View File

@ -41,7 +41,7 @@ static ALvoid ALnullState_update(ALnullState* UNUSED(state), const ALCdevice* UN
* input to the output buffer. The result should be added to the output buffer,
* not replace it.
*/
static ALvoid ALnullState_process(ALnullState* UNUSED(state), ALuint UNUSED(samplesToDo), const ALfloat *restrict UNUSED(samplesIn), ALfloatBUFFERSIZE*restrict UNUSED(samplesOut), ALuint UNUSED(NumChannels))
static ALvoid ALnullState_process(ALnullState* UNUSED(state), ALuint UNUSED(samplesToDo), const ALfloatBUFFERSIZE*restrict UNUSED(samplesIn), ALfloatBUFFERSIZE*restrict UNUSED(samplesOut), ALuint UNUSED(NumChannels))
{
}

View File

@ -627,12 +627,12 @@ static ALvoid ALreverbState_processEax(ALreverbState *State, ALuint SamplesToDo,
}
}
static ALvoid ALreverbState_process(ALreverbState *State, ALuint SamplesToDo, const ALfloat *restrict SamplesIn, ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
static ALvoid ALreverbState_process(ALreverbState *State, ALuint SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALuint NumChannels)
{
if(State->IsEax)
ALreverbState_processEax(State, SamplesToDo, SamplesIn, SamplesOut, NumChannels);
ALreverbState_processEax(State, SamplesToDo, SamplesIn[0], SamplesOut, NumChannels);
else
ALreverbState_processStandard(State, SamplesToDo, SamplesIn, SamplesOut, NumChannels);
ALreverbState_processStandard(State, SamplesToDo, SamplesIn[0], SamplesOut, NumChannels);
}
// Given the allocated sample buffer, this function updates each delay line

View File

@ -22,7 +22,7 @@ struct ALeffectStateVtable {
ALboolean (*const deviceUpdate)(ALeffectState *state, ALCdevice *device);
void (*const update)(ALeffectState *state, const ALCdevice *device, const struct ALeffectslot *slot);
void (*const process)(ALeffectState *state, ALuint samplesToDo, const ALfloat *restrict samplesIn, ALfloat (*restrict samplesOut)[BUFFERSIZE], ALuint numChannels);
void (*const process)(ALeffectState *state, ALuint samplesToDo, const ALfloat (*restrict samplesIn)[BUFFERSIZE], ALfloat (*restrict samplesOut)[BUFFERSIZE], ALuint numChannels);
void (*const Delete)(void *ptr);
};
@ -31,7 +31,7 @@ struct ALeffectStateVtable {
DECLARE_THUNK(T, ALeffectState, void, Destruct) \
DECLARE_THUNK1(T, ALeffectState, ALboolean, deviceUpdate, ALCdevice*) \
DECLARE_THUNK2(T, ALeffectState, void, update, const ALCdevice*, const ALeffectslot*) \
DECLARE_THUNK4(T, ALeffectState, void, process, ALuint, const ALfloat*restrict, ALfloatBUFFERSIZE*restrict, ALuint) \
DECLARE_THUNK4(T, ALeffectState, void, process, ALuint, const ALfloatBUFFERSIZE*restrict, ALfloatBUFFERSIZE*restrict, ALuint) \
static void T##_ALeffectState_Delete(void *ptr) \
{ return T##_Delete(STATIC_UPCAST(T, ALeffectState, (ALeffectState*)ptr)); } \
\