@@ -177,9 +177,6 @@ constexpr uint16_t samplesFFT_2 = 256; // meaningfull part of FFT resul
177
177
// These are the input and output vectors. Input vectors receive computed results from FFT.
178
178
static float vReal[samplesFFT] = {0 .0f }; // FFT sample inputs / freq output - these are our raw result bins
179
179
static float vImag[samplesFFT] = {0 .0f }; // imaginary parts
180
- #ifdef UM_AUDIOREACTIVE_USE_NEW_FFT
181
- static float windowWeighingFactors[samplesFFT] = {0 .0f };
182
- #endif
183
180
184
181
// Create FFT object
185
182
#ifdef UM_AUDIOREACTIVE_USE_NEW_FFT
@@ -198,9 +195,15 @@ static float windowWeighingFactors[samplesFFT] = {0.0f};
198
195
#include < arduinoFFT.h>
199
196
200
197
#ifdef UM_AUDIOREACTIVE_USE_NEW_FFT
201
- static ArduinoFFT<float > FFT = ArduinoFFT<float >( vReal, vImag, samplesFFT, SAMPLE_RATE, windowWeighingFactors);
198
+ #if defined(FFT_LIB_REV) && FFT_LIB_REV > 0x19
199
+ // arduinoFFT 2.x has a slightly different API
200
+ static ArduinoFFT<float > FFT = ArduinoFFT<float >( vReal, vImag, samplesFFT, SAMPLE_RATE, true );
201
+ #else
202
+ static float windowWeighingFactors[samplesFFT] = {0 .0f }; // cache for FFT windowing factors
203
+ static ArduinoFFT<float > FFT = ArduinoFFT<float >( vReal, vImag, samplesFFT, SAMPLE_RATE, windowWeighingFactors);
204
+ #endif
202
205
#else
203
- static arduinoFFT FFT = arduinoFFT(vReal, vImag, samplesFFT, SAMPLE_RATE);
206
+ static arduinoFFT FFT = arduinoFFT(vReal, vImag, samplesFFT, SAMPLE_RATE);
204
207
#endif
205
208
206
209
// Helper functions
@@ -300,7 +303,12 @@ void FFTcode(void * parameter)
300
303
#endif
301
304
302
305
#ifdef UM_AUDIOREACTIVE_USE_NEW_FFT
306
+ #if defined(FFT_LIB_REV) && FFT_LIB_REV > 0x19
307
+ // arduinoFFT 2.x has a slightly different API
308
+ FFT.majorPeak (&FFT_MajorPeak, &FFT_Magnitude); // let the effects know which freq was most dominant
309
+ #else
303
310
FFT.majorPeak (FFT_MajorPeak, FFT_Magnitude); // let the effects know which freq was most dominant
311
+ #endif
304
312
#else
305
313
FFT.MajorPeak (&FFT_MajorPeak, &FFT_Magnitude); // let the effects know which freq was most dominant
306
314
#endif
0 commit comments