Inverse FFT - how to synchronize the phase in each buffer block

Yes I know that, everybody told me that. But I am just curious to understand that. It is just interesting for me. And other purpose is to train the C++ programming

OK, so it’s just time to move on further :slight_smile:

Nothing wrong with that. (I can admit my patience wouldn’t last to implement something like FFT for which so many implementations already exists.) But now you have to also learn how to actually use the FFT
 :wink:

That’s what I am asking for :slight_smile: Could you tell me? How and for what?

I am not that qualified to explain “how” but some ideas for “what” :

-Fast convolution, for complicated filters, reverb, guitar cabinet simulation (Reverb is not terribly exciting though, the quality of the results entirely depends on the available impulse response recordings and the result will be pretty static anyway. Time is probably better spent doing time domain reverb algorithms.)
-Pitch shift, frequency shift, time stretch and time freeze
-Very strange processings like can be done with the GRM Tools ST and Evolution plugin bundles
-Spectrum analyzer

That’s the huge answer for me :slight_smile: Really thanks :slight_smile:

Probably in order of complexity indeed:

  • spectrum analysis
  • fast convolution
  • time freeze
  • time stretch/pitch changes
    But going from convolution to time freeze requires studying the books. Signal processing is a big subject, convolution and spectrum analysis are more or less Signal processing 101. The algorithms that are interesting are more or less PhD level.
1 Like

As Matthieu pointed out, complete algorithms that are useful for real-world problems might become quite complex. However doing your own implementation of fft algorithms shows that you are not scared of complex tasks. TBH, as a daily user of the algorithm itself I never ever tried implementing an FFT by myself and so did most others here. Your approach sounds a bit like “I built a diesel engine and a petrol engine, but I have no idea what to do with it. Could somebody explain to me what a car is?” :smiley:

But to break down the basic idea of the Fourier transform let me just give you a quick overview what it does:
Theory says, that you can recreate ANY arbitrary signal by taking an endless number of sine waves with ascending frequencies, aply a certain time shift to each of these waves, scale each wave by a certain factor and then add all those waves. This will give you the exact signal form you started with. But as the length of real-world signals is practically infinite, you will need an infinite number of sines to recreate such a signal. Now a discrete fourier transform assumes that you have a sampled signal that is periodic after N samples and that you want to get the description of the N sine waves that perfectly recreate this periodic signal. So you throw one period of N samples into your dft and it will output N complex numbers, which contain information about the time shift needed for each of the single sines (the phase angle of the complex number) and of the amplitude scaling (the absolute value of the complex number).
Now what do we do in real world problems? We have infinite, continuous input signals, take snippets out of it and put it into a dft. We now get some information we didn’t have before, e.g. what frequencies are dominant in that snippet - those informations are used for spectrum analysis. One step further is then to manipulate the spectrum and transform it back. But wait, what did I say? The theory says that those frequency bins describe how to create a periodic signal. Now manipulating things in the frequency domain and putting the result back together into the time domain just doesn’t work that simple as you violate the theory that you are working on periodic signals while you are actually working on a snippet of an infinite, non-periodic signal. This is the main reason why two blocks might not match perfectly when putting them back together in the time domain after having manipulated them in the frequency domain. There are ways to overcome this issue, but to explain them there is no way around some serious math.

Some of the things usually done with the help of the fft could be done directly in the time domain. However as you may have noticed, while a dft of an arbitrary size is computational heavy, an fft working on a size of 2^n is quite efficient. And for some algorithms, it’s just much more efficient to compute the fft, do some manipulation in the frequency domain and transform it back compared to do the same thing directly on time domain samples, even with the needed overhead of overlapping windows, etc. In fact, convolution reverbs (which most people usually would describe as algorithms working on the “time-aspect” of a signal) would be practically impossible to build when calculating the result completely in the time domain.

Hope that gives you some hints. If you want to get started, maybe first have a read on time domain convolution. Then you will sooner or later come to the point where the fft is helpful.

4 Likes

I’d recommend reading (at least!) the appropriate chapters from this free online book:

http://www.dspguide.com/pdfbook.htm

4 Likes

I also would recommend using something like Matlab, Octava, Python (numerical computation environment) to learn about FFT or signal processing in general, instead of using C++&JUCE as data visualization is quite complicated. In Matlab and co., that’s very easy. So you can easily see what’s wrong, and what you have to do in order to correct it.

Once your algorithm works in those environments, you can transport it to JUCE.

2 Likes