0
votes

I wrote some code that takes an audio signal (currently a sine wave) as an input and does the following:

  1. Take frames of n (1024) samples
  2. Apply FFT
  3. Apply iFFT
  4. Play output

With this process the output signal is basically the same as the input signal.

Now, in a second attempt I do:

  1. Take overlapping frames from the input
  2. Apply a window function
  3. FFT
  4. iFFT
  5. Overlap the output frames

In step 1, if I take overlapping frames using a hop size (number of samples to jump to take next frame) of a power of 2 (4, 8, 256...) the output sound is smooth and resembles the original input sound, but with any other hop size, the sound starts to crack down. This happens for any frequency of the input signal. Question 1. Why is the sound smooth only if the hop size is 2^n?.

Currently I use a Hanning window. When the hop size is large (e.g. 512) the output sound has a lower volume than when the hop size is small (e.g.64). This seems an expected behavior, because a small hop-size implies that a sample is reconstructed with more frames, so more signals are added. Question 2. Is there a way to properly scale the output signal so that the volume resembles the original signal?

Thank you!

2

2 Answers

2
votes

This should not be happening, Overlap-add method can reconstruct your signal without the problems described, we not know exactly what are you doing, I did it some time ago and its works for any hop size and window size, a small secret is apply zeros after and before your signal to ensure a continuous signal, if you look calmly will realize that your window function works like a fade-in/fade-out if you just concatenate the frames you will notice some clicks or the output signal will look like a vibrato, gets a little tricky to tell where your problem actually find !

Just for Debug, skip the FFT and iFFT steps and see if your signal was correctly constructed, if yes your overlap-add process works, and your problem can be in your FFT/iFFT ...

1
votes

Overlap-add is normally done without using a non-rectangular window function. Zero-pad instead.

If you do use a window function, then you have to make sure that all the offset window functions sum to a constant level, which for a Von Hann window happens with certain offsets (except at the very beginning or end of the series sum). As

2 - (cos(x)+cos(x+Pi)) == 2

Sum more windows into a result without any scaling, and of course the level of the sum will increase.