STFT overlap add method - What am i doing wrong? 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&lt;(length/stftWindowSizeOver2)-1;i++){

    //apply hamming window and copy to complex arrays
    vDSP_vmul(&amp;mic[i*stftWindowSizeOver2],1,stftHamming,1,stftTmpStorage,1,stftWindowSize);
    vDSP_ctoz((DSPComplex *)stftTmpStorage, 2, &amp;stftMic, 1, stftWindowSize);

    //fft
    vDSP_fft_zrip(stftSetup, &amp;stftMic, 1, stftLog2n, FFT_FORWARD);

    //here shold the filtering happen right?

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

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

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

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

    vDSP_vadd(stftTmpStorage,1,&amp;mic[i*stftWindowSizeOver2],1,&amp;mic[i*stftWindowSizeOver2],1,stftWindowSize);
}


basically what im trying to do here is:


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
apply hamming window
compute FFT of the chunk + zeros at the end of signal with overall length: stftN
compute inverse FFT
scale back as a result of the FFT
clear non overlapping area in innput/output signal mic.
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!
I think, the problem lies here:


  
  scale back as a result of the FFT
  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.