mirror of
https://codeberg.org/armin/horizont.git
synced 2026-09-01 12:20:47 +02:00
43 lines
1.2 KiB
C
43 lines
1.2 KiB
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <JuceHeader.h>
|
||
|
|
|
||
|
|
#include <array>
|
||
|
|
|
||
|
|
#include "PluginProcessor.h"
|
||
|
|
|
||
|
|
class SpectrumDisplay : public juce::Component, private juce::Timer
|
||
|
|
{
|
||
|
|
public:
|
||
|
|
explicit SpectrumDisplay (HorizontAudioProcessor&);
|
||
|
|
~SpectrumDisplay() override;
|
||
|
|
|
||
|
|
void paint (juce::Graphics&) override;
|
||
|
|
void setScaleFactor (float scale);
|
||
|
|
|
||
|
|
private:
|
||
|
|
void timerCallback() override;
|
||
|
|
|
||
|
|
HorizontAudioProcessor& processor;
|
||
|
|
|
||
|
|
static constexpr int fftOrder = 10;
|
||
|
|
static constexpr int fftSize = 1 << fftOrder;
|
||
|
|
static constexpr int numBins = 48;
|
||
|
|
|
||
|
|
void computeLevels (const float* samples, int got, std::array<float, numBins>& out);
|
||
|
|
juce::Path makeCurve (const juce::Rectangle<float>& graph, const std::array<float, numBins>& data) const;
|
||
|
|
|
||
|
|
juce::dsp::FFT fft { fftOrder };
|
||
|
|
std::vector<float> fftData = std::vector<float> (2 * fftSize, 0.0f);
|
||
|
|
std::vector<float> window;
|
||
|
|
std::array<float, numBins> level {};
|
||
|
|
std::array<float, numBins> display {};
|
||
|
|
std::array<float, numBins> peak {};
|
||
|
|
std::array<float, numBins> dryLevel {};
|
||
|
|
std::array<float, numBins> dryDisplay {};
|
||
|
|
std::array<float, numBins> dryPeak {};
|
||
|
|
|
||
|
|
float scaleFactor = 1.0f;
|
||
|
|
|
||
|
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SpectrumDisplay)
|
||
|
|
};
|