reVeno/Source/Veno/Utils/FFT.h

34 lines
726 B
C
Raw Normal View History

2020-06-13 10:56:20 +02:00
//
// Created by versustune on 12.06.20.
//
#ifndef VENO_FFT_H
#define VENO_FFT_H
#include "JuceHeader.h"
class FFT
{
2020-06-13 10:56:20 +02:00
private:
public:
FFT () = default;
~FFT () = default;
2020-06-13 10:56:20 +02:00
void pushNextSampleIntoFifo (float sample) noexcept;
enum
{
fftOrder = 11, // [1]
fftSize = 1 << fftOrder, // [2]
2020-06-13 10:56:20 +02:00
scopeSize = 512 // [3]
};
void drawNextFrameOfSpectrum ();
2020-06-13 10:56:20 +02:00
bool nextFFTBlockReady = false;
float scopeData[scopeSize]{};
float fftData[2 * fftSize]{};
2020-06-13 10:56:20 +02:00
protected:
dsp::FFT fft{fftOrder};
dsp::WindowingFunction<float> window{fftSize, dsp::WindowingFunction<float>::hann};
float fifo[fftSize]{};
2020-06-13 10:56:20 +02:00
int fifoIndex = 0;
};
#endif //VENO_FFT_H