reVeno/Source/Veno/Utils/FFT.cpp
versustunez ac22ea5e75 - reformat to JUCE-Guidelines
- added Matrix => half working ;)
2020-06-13 16:52:16 +02:00

37 lines
902 B
C++

//
// Created by versustune on 12.06.20.
//
#include "FFT.h"
void FFT::pushNextSampleIntoFifo (float sample) noexcept
{
{
if (fifoIndex == fftSize) // [11]
{
if (!nextFFTBlockReady) // [12]
{
zeromem (fftData, sizeof (fftData));
memcpy (fftData, fifo, sizeof (fifo));
nextFFTBlockReady = true;
}
fifoIndex = 0;
}
fifo[fifoIndex++] = sample; // [12]
}
}
void FFT::drawNextFrameOfSpectrum ()
{
window.multiplyWithWindowingTable (fftData, fftSize); // [1]
fft.performFrequencyOnlyForwardTransform (fftData); // [2]
auto mindB = -80.0f;
auto maxdB = 0.0f;
for (int i = 0; i < scopeSize; ++i)
{
auto level = jmap (Decibels::gainToDecibels (fftData[i], mindB), mindB, maxdB, -1.0f, 1.0f);
scopeData[i] = level;
}
}