i am trying to implement a short time fourier transform of an audio signal to do some filtering (subtract another stft signal using spectral subtraction). I am using a hamming window function with 50% overlap. Additional the size of my FFT is twice the window size, zeros at the end of the signal in time domain.

mic is the input and output signal for in-place filtering

here is my code for so far:

    stftWindowSize = 256;
    stftWindowSizeOver2 = stftWindowSize/2;
    stftN = 512;
    stftLog2n = log2(stftN);
    stftNOver2 = stftN/2;
    stftSetup = vDSP_create_fftsetup (stftLog2n, FFT_RADIX2);

//length is the complete signal to be processed
for(i = 0;i<(length/stftWindowSizeOver2)-1;i++){

    //apply hamming window and copy to complex arrays
    vDSP_ctoz((DSPComplex *)stftTmpStorage, 2, &stftMic, 1, stftWindowSize);

    vDSP_fft_zrip(stftSetup, &stftMic, 1, stftLog2n, FFT_FORWARD);

    //here shold the filtering happen right?

    //inverse fft
    vDSP_fft_zrip(stftSetup, &stftMic, 1, stftLog2n, FFT_INVERSE);

    //scale back
    float scale = 2*stftN;
    vDSP_vsdiv(stftMic.realp, 1, &scale, stftMic.realp, 1, stftNOver2);
    vDSP_vsdiv(stftMic.imagp, 1, &scale, stftMic.imagp, 1, stftNOver2);

    //mic data back to real, clear original signal and add overlapping data back in
    vDSP_ztoc(&stftMic, 1, (COMPLEX *)stftTmpStorage, 2, stftWindowSizeOver2);

    //set old signal to zero in non overlapping area and add
        vDSP_vclr(mic, 1, stftWindowSize);
        vDSP_vclr(&mic[(i+1)*stftWindowSizeOver2], 1, stftWindowSizeOver2);


basically what im trying to do here is:

  1. get chunk of float data of length: stftWindowSize (only half the data is "new" due to 50% overlap with previous chunk) from input/output signal mic
  2. apply hamming window
  3. compute FFT of the chunk + zeros at the end of signal with overall length: stftN
  4. compute inverse FFT
  5. scale back as a result of the FFT
  6. clear non overlapping area in innput/output signal mic.
  7. add my processed iFFT data back into mic with a 50% overlap with previous chunk data.

My Problem:
as i'm not doing anything with my FFT-data the sound should be the same as before, but unfortunately it isn't. It sounds somewhat modified and especially low frequencies look significantly changed when i look at the spectrum of the signal before and after my STFT.

What am i doing wrong? have i misunderstood the zero padding? is this method suited for filtering (especially spectral subtraction)?
i hope you can help me!

  • 1
    $\begingroup$ "especially low frequencies look significantly changed when i look at the spectrum of the signal before and after my STFT" can you plot this? $\endgroup$
    – endolith
    Commented Sep 12, 2014 at 19:31
  • $\begingroup$ I believe you should make sure that you fulfil the COLA constraints with the window type and overlap percentage. For more information on COLA, you can look here: dsprelated.com/freebooks/sasp/… $\endgroup$
    – ZaellixA
    Commented Mar 28, 2020 at 16:02

2 Answers 2


I think, the problem lies here:

  1. scale back as a result of the FFT
  2. clear non overlapping area in innput/output signal mic.

Why are you doing this? You are using a Hamming window with 50% overlap, summed up, this yields a constant one. If you delete the "non overlapping" part, you effectively change the window you are using to a weird "half hamming" one, this is bound to yield incorrect results. Skip these two steps, and you should be fine.


It looks to me as if you are trying to do a FIR filtering with a long impulse response. The correct way of doing this using FFT is either the "Overlap add" or the "Overlap save" method. Both methods are well described on Wikipedia even with programming examples.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.