» vux-doc-ftttricks
This site relies heavily on Javascript. You should enable it if you want the full experience. Learn more.

vux-doc-ftttricks

Italian

FFT Tricks

Here I'm gonna give some tricks/facts about Fast Fourier Transform, and how to use it.

Some useful FFT properties

  • When you compute a FFT, the maximum frequency you can retrieve is the samplerate divided by 2 (Also known as Nyquist Frequency).
  • FFT is a mirrored function, which means that the second half of the FFT should be a mirror of the first half (so normally you only need to use the first half).
  • The first bin of a FFT is called DC (Direct Current). It represents a frequency of 0Hz, which is not possible in theory. This number is the average of all the samples (normal samples, not fft samples).

FFT Size and buffer

the size of the FFT (also called resolution) gives you a greater accuracy as the number is higher.

To perform higher resolution, you also need more samples.

The formula is:
Samples Required = 1000 * FFTSize / SampleRate

So to calculate a 1024 bins FFT on a 44100Hz file, you need:
1000*1024/44100 = 23.21 milliseconds worth of data (so let's say 24 :)

Get FFT Bin from a frequency

The formula to find the Bin from a frequency is:
Resolution*Frequency/SampleRate

So if our FFT is 512 bins, and our file samplerate is 44100Hz, then the bin for 440Hz is:
512*440/44100 = 5.10

Which means that most of the energy for the frequency is in the Bin 5, and a small part of it is in the bin 6.

Get the Frequency from a FFT bin

As opposite, the formula to find frequency from a bin is:
Bin*SampleRate/Resolution

So the Bin 35 of a 512 FFT (sample rate as 44100Hz) is:
35*44100/512 = 3014.64Hz

Trick to process FFT

Most of the time, some high frequency bins will be very low (harmonics).
To help this , you can use the following nodes:

  • * (Value): This is the obvious, but you will double everything, and some might go outside the 0..1 range.
  • Sqrt: This is my favorite, as low peak will increase more, and high peaks will almost not change. And values will stay between 0 and 1.
  • Log : This converts the values to a log scale, useful for equalizers, but I find you lose a bit the peaks.
  • GetSpreads and Mean: You can also easily split the bins and calculate the bands like an equalizer, you lose resolution, but have less data to process. This fits pretty well for patch which will not use the same music all the time.

That's it for the moment.
I will add some help patches to try to explain some features, and add new ones as well :)

by vux

anonymous user login

Shoutbox

~4d ago

joreg: vvvvTv S02E01 is out: Buttons & Sliders with Dear ImGui: https://www.youtube.com/live/PuuTilbqd9w

~10d ago

joreg: vvvvTv S02E00 is out: Sensors & Servos with Arduino: https://visualprogramming.net/blog/2024/vvvvtv-is-back-with-season-2/

~10d ago

~11d ago

fleg: hey there! What's the best tool for remote work? Teamviewer feels terrible. Thanks!

~24d ago

joreg: Last call: 6-session vvvv beginner course starting November 4: https://thenodeinstitute.org/courses/ws24-5-vvvv-beginners-part-i/

~1mth ago

joreg: Missed the last meetup? You can rewatch it here: https://www.youtube.com/live/MdvTa58uxB0?si=Fwi-9hHoCmo794Ag

~1mth ago

theurbankind: When is the next big event, like node festival ?

~1mth ago

~1mth ago

joreg: Join us for the next vvvv meetup on Oktober 17th: https://visualprogramming.net/blog/2024/25.-vvvv-worldwide-meetup/

~2mth ago

joreg: 6 session beginner course part 2 "Deep Dive" starts January 13th: https://thenodeinstitute.org/courses/ws24-5-vvvv-beginners-part-ii/