Skip to content

Commit

Permalink
Merge pull request #88509 from akien-mga/pitchshift-unsigned-fft-size
Browse files Browse the repository at this point in the history
AudioEffectPitchShift: Prevent negative size memset (GCC warning)
  • Loading branch information
akien-mga committed Feb 20, 2024
2 parents b652a81 + 3ba724e commit dbf5980
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions servers/audio/effects/audio_effect_pitch_shift.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
double magn, phase, tmp, window, real, imag;
double freqPerBin, expct;
long i,k, qpd, index, inFifoLatency, stepSize, fftFrameSize2;
unsigned long fftFrameBufferSize;

/* set up some handy variables */
fftFrameBufferSize = (unsigned long)fftFrameSize*sizeof(float);
fftFrameSize2 = fftFrameSize/2;
stepSize = fftFrameSize/osamp;
freqPerBin = sampleRate/(double)fftFrameSize;
Expand Down Expand Up @@ -160,8 +162,8 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff

/* ***************** PROCESSING ******************* */
/* this does the actual pitch shifting */
memset(gSynMagn, 0, fftFrameSize*sizeof(float));
memset(gSynFreq, 0, fftFrameSize*sizeof(float));
memset(gSynMagn, 0, fftFrameBufferSize);
memset(gSynFreq, 0, fftFrameBufferSize);
for (k = 0; k <= fftFrameSize2; k++) {
index = k*pitchShift;
if (index <= fftFrameSize2) {
Expand Down Expand Up @@ -214,7 +216,7 @@ void SMBPitchShift::PitchShift(float pitchShift, long numSampsToProcess, long ff
}

/* shift accumulator */
memmove(gOutputAccum, gOutputAccum+stepSize, fftFrameSize*sizeof(float));
memmove(gOutputAccum, gOutputAccum+stepSize, fftFrameBufferSize);

/* move input FIFO */
for (k = 0; k < inFifoLatency; k++) { gInFIFO[k] = gInFIFO[k+stepSize];
Expand Down

0 comments on commit dbf5980

Please sign in to comment.