diff options
author | Chris Robinson <[email protected]> | 2018-03-22 08:15:50 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-03-22 08:49:22 -0700 |
commit | 23fd7451d00697c2be6c16266305c1366fc3b57e (patch) | |
tree | 41784783b55adfaac24c982a812c927da7b1bb68 /Alc/effects/pshifter.c | |
parent | bc3a96308e04f5a6e1df7cf5c0f9e9c86931d4ec (diff) |
Avoid some memset calls in the pitch shifter process loop
Diffstat (limited to 'Alc/effects/pshifter.c')
-rw-r--r-- | Alc/effects/pshifter.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/Alc/effects/pshifter.c b/Alc/effects/pshifter.c index 4017dc0a..2110141c 100644 --- a/Alc/effects/pshifter.c +++ b/Alc/effects/pshifter.c @@ -326,14 +326,18 @@ static ALvoid ALpshifterState_process(ALpshifterState *state, ALsizei SamplesToD /* PROCESSING */ /* pitch shifting */ - memset(state->Syntesis_buffer, 0, sizeof(state->Syntesis_buffer)); + for(k = 0;k < STFT_HALF_SIZE+1;k++) + { + state->Syntesis_buffer[k].Amplitude = 0.0f; + state->Syntesis_buffer[k].Frequency = 0.0f; + } for(k = 0;k < STFT_HALF_SIZE+1;k++) { j = fastf2i((ALfloat)k * state->PitchShift); if(j >= STFT_HALF_SIZE+1) break; - state->Syntesis_buffer[j].Amplitude += state->Analysis_buffer[k].Amplitude; + state->Syntesis_buffer[j].Amplitude += state->Analysis_buffer[k].Amplitude; state->Syntesis_buffer[j].Frequency = state->Analysis_buffer[k].Frequency * state->PitchShift; } @@ -357,9 +361,12 @@ static ALvoid ALpshifterState_process(ALpshifterState *state, ALsizei SamplesToD /* Compute phasor component to cartesian complex number and storage it into FFTbuffer*/ state->FFTbuffer[k] = polar2rect(component); } - /* zero negative frequencies for recontruct a real signal */ - memset(&state->FFTbuffer[STFT_HALF_SIZE+1], 0, (STFT_HALF_SIZE-1)*sizeof(ALcomplex)); + for(k = STFT_HALF_SIZE+1;k < STFT_SIZE;k++) + { + state->FFTbuffer[k].Real = 0.0f; + state->FFTbuffer[k].Imag = 0.0f; + } /* Apply iFFT to buffer data */ FFT(state->FFTbuffer, STFT_SIZE, 1.0f); |