diff options
author | Chris Robinson <[email protected]> | 2018-03-22 02:29:34 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-03-22 03:13:09 -0700 |
commit | 6ad171781a8e2270f598263149356385cc06d8f9 (patch) | |
tree | dca5aaaeda2734e006c388261be0594f0f7e6418 | |
parent | d157d66678ed634550ca5991dde9c68178c41768 (diff) |
Use the global MixSamples for the pitch shifter output
-rw-r--r-- | Alc/effects/pshifter.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/Alc/effects/pshifter.c b/Alc/effects/pshifter.c index 137c7d04..d36597ae 100644 --- a/Alc/effects/pshifter.c +++ b/Alc/effects/pshifter.c @@ -75,10 +75,11 @@ typedef struct ALpshifterState { ALfrequencyDomain Analysis_buffer[MAX_SIZE]; ALfrequencyDomain Syntesis_buffer[MAX_SIZE]; - ALfloat BufferOut[BUFFERSIZE]; + alignas(16) ALfloat BufferOut[BUFFERSIZE]; /* Effect gains for each output channel */ - ALfloat Gain[MAX_OUTPUT_CHANNELS]; + ALfloat CurrentGains[MAX_OUTPUT_CHANNELS]; + ALfloat TargetGains[MAX_OUTPUT_CHANNELS]; } ALpshifterState; static ALvoid ALpshifterState_Destruct(ALpshifterState *state); @@ -237,6 +238,9 @@ static ALboolean ALpshifterState_deviceUpdate(ALpshifterState *state, ALCdevice memset(state->OutputAccum, 0, sizeof(state->OutputAccum)); memset(state->Analysis_buffer, 0, sizeof(state->Analysis_buffer)); + memset(state->CurrentGains, 0, sizeof(state->CurrentGains)); + memset(state->TargetGains, 0, sizeof(state->TargetGains)); + return AL_TRUE; } @@ -250,7 +254,7 @@ static ALvoid ALpshifterState_update(ALpshifterState *state, const ALCcontext *c ); CalcAngleCoeffs(0.0f, 0.0f, 0.0f, coeffs); - ComputeDryPanGains(&device->Dry, coeffs, slot->Params.Gain, state->Gain); + ComputeDryPanGains(&device->Dry, coeffs, slot->Params.Gain, state->TargetGains); } static ALvoid ALpshifterState_process(ALpshifterState *state, ALsizei SamplesToDo, const ALfloat (*restrict SamplesIn)[BUFFERSIZE], ALfloat (*restrict SamplesOut)[BUFFERSIZE], ALsizei NumChannels) @@ -372,17 +376,9 @@ static ALvoid ALpshifterState_process(ALpshifterState *state, ALsizei SamplesToD memmove(state->InFIFO , state->InFIFO +STFT_STEP, FIFO_LATENCY*sizeof(ALfloat)); } - /* Now, mix the processed sound data to the output*/ - for (j = 0; j < NumChannels; j++ ) - { - ALfloat gain = state->Gain[j]; - - if(!(fabsf(gain) > GAIN_SILENCE_THRESHOLD)) - continue; - - for(i = 0;i < SamplesToDo;i++) - SamplesOut[j][i] += gain * bufferOut[i]; - } + /* Now, mix the processed sound data to the output. */ + MixSamples(bufferOut, NumChannels, SamplesOut, state->CurrentGains, state->TargetGains, + maxi(SamplesToDo, 512), 0, SamplesToDo); } typedef struct PshifterStateFactory { |