This commit is contained in:
Maurice Grönwoldt 2020-06-13 10:56:20 +02:00
commit 26a2935e1c
52 changed files with 1513 additions and 107 deletions

35
Source/Veno/Utils/FFT.cpp Normal file
View file

@ -0,0 +1,35 @@
//
// 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;
}
}

34
Source/Veno/Utils/FFT.h Normal file
View file

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

View file

@ -0,0 +1,17 @@
//
// Created by versustune on 09.06.20.
//
#include "Logger.h"
void VeNo::Logger::debugMessage(const std::string &message) {
#ifdef DEBUG
std::cout << "\u001b[38;5;172m[DEBUG]\u001b[0m\t" << message << "\n";
#endif
}
void VeNo::Logger::infoDebugMessage(const std::string &message) {
#ifdef DEBUG
std::cout << "\u001b[38;5;111m[INFO]\u001b[0m\t" << message << "\n";
#endif
}

View file

@ -0,0 +1,16 @@
#ifndef VENO_LOGGER_H
#define VENO_LOGGER_H
#include <iostream>
namespace VeNo {
class Logger {
public:
static void debugMessage(const std::string &message);
static void infoDebugMessage(const std::string &message);
};
}
#endif //VENO_LOGGER_H