27 lines
1009 B
C
27 lines
1009 B
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <Arduino.h>
|
||
|
|
#include "Config.h"
|
||
|
|
#include "NoteDetector.h"
|
||
|
|
|
||
|
|
class SpectrumVisualizer {
|
||
|
|
public:
|
||
|
|
// Visualization settings
|
||
|
|
static constexpr int DISPLAY_WIDTH = 80; // Characters wide
|
||
|
|
static constexpr int DISPLAY_HEIGHT = 16; // Lines tall
|
||
|
|
static constexpr float DB_MIN = 30.0f; // Minimum dB to show
|
||
|
|
static constexpr float DB_MAX = 90.0f; // Maximum dB to show
|
||
|
|
|
||
|
|
static void visualizeSpectrum(const double* spectrum, int size);
|
||
|
|
static void visualizeNotes(const std::vector<DetectedNote>& notes);
|
||
|
|
static void drawFFTMagnitudes(const double* magnitudes, int size, bool logScale = true);
|
||
|
|
|
||
|
|
private:
|
||
|
|
static constexpr const char* noteNames[] = {
|
||
|
|
"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"
|
||
|
|
};
|
||
|
|
|
||
|
|
static float magnitudeToDb(double magnitude);
|
||
|
|
static int mapToDisplay(float value, float min, float max, int displayMin, int displayMax);
|
||
|
|
static void printBarGraph(float value, float maxValue, int width);
|
||
|
|
};
|