Skip to content

Commit a68df97

Browse files
committed
updated fft objects to new code
1 parent 715fb5d commit a68df97

4 files changed

Lines changed: 14 additions & 8 deletions

File tree

src/objects/audio_analysis/AudioAnalyzer.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,15 @@ void AudioAnalyzer::loadAudioSettings(){
316316
beatTrack->setConfidentThreshold(0.35);
317317

318318
// Audio Analysis
319-
fft = ofxFft::create(bufferSize, OF_FFT_WINDOW_HAMMING);
319+
fft = new ofxVP::Fft();
320+
fft->setup(bufferSize);
320321

321-
fftBinSize = fft->getBinSize();
322-
fft_binSizeHz = ((sampleRate/2)/(fftBinSize-1));
322+
fftBinSize = (bufferSize / 2) + 1;
323+
// avoid division by 0
324+
if(fftBinSize<=1){
325+
fftBinSize = 2;
326+
}
327+
fft_binSizeHz = (sampleRate/2)/(fftBinSize-1);
323328
fft_StrongestBinValue = 0.0f;
324329
fft_StrongestBinIndex = 0;
325330
fft_pitchBin = 0;

src/objects/audio_analysis/AudioAnalyzer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
#include "PatchObject.h"
3838

39-
#include "ofxFft.h"
39+
#include "ofxVPFFT.h"
4040
#include "ofxBTrack.h"
4141

4242
#include "imgui_plot.h"
@@ -82,7 +82,7 @@ class AudioAnalyzer : public PatchObject {
8282
std::mutex audioMutex;
8383

8484
// Analysis variables
85-
ofxFft *fft;
85+
ofxVP::Fft *fft;
8686
ofxBTrack *beatTrack;
8787

8888
float *plot_data;

src/objects/sound/pdspParametricEQ.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,8 @@ void pdspParametricEQ::loadAudioSettings(){
340340
sampleRate = this->ofxVPXml.getMosaicConfigInt("sample_rate_in");
341341
bufferSize = this->ofxVPXml.getMosaicConfigInt("buffer_size");
342342

343-
fft = ofxFft::create(bufferSize, OF_FFT_WINDOW_HAMMING);
343+
fft = new ofxVP::Fft();
344+
fft->setup(bufferSize);
344345
spectrum = new float[fft->getBinSize()];
345346
l1Filter = new std::vector<float>;
346347
m1Filter = new std::vector<float>;

src/objects/sound/pdspParametricEQ.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
#include "PatchObject.h"
3838

39-
#include "ofxFft.h"
39+
#include "ofxVPFFT.h"
4040

4141
#include "imgui_plot.h"
4242
#include "imgui-knobs.h"
@@ -65,7 +65,7 @@ class pdspParametricEQ : public PatchObject{
6565
void loadAudioSettings();
6666

6767

68-
ofxFft *fft;
68+
ofxVP::Fft *fft;
6969
float *spectrum;
7070

7171
pdsp::Scope scope;

0 commit comments

Comments
 (0)