Visualizing FFT
In this recipe, we will show an example of FFT (Fast Fourier Transform) data visualization on a circular layout with some smooth animation.
Getting ready
Save you favorite music piece in assets folder with the name music.mp3
.
How to do it…
We will create visualization based on an example FFT analysis using the following steps:
Include the following necessary header files:
#include "cinder/gl/gl.h" #include "cinder/audio/Io.h" #include "cinder/audio/Output.h" #include "cinder/audio/FftProcessor.h" #include "cinder/audio/PcmBuffer.h"
Add the following members to your main application class:
void drawFft(); audio::TrackRef mTrack; audio::PcmBuffer32fRef mPcmBuffer; uint16_t bandCount; float levels[32]; float levelsPts[32];
Inside the
setup
method, initialize the members and load the sound file from the assets folder. We are decomposing the signal into 32 frequencies using FFT:bandCount = 32; std::fill(boost::begin(levels), boost::end(levels), 0.f); std::fill(boost::begin(levelsPts),...