FahlGrahn Audio v1.0.0
Loading...
Searching...
No Matches
EQView.h
1#pragma once
2
3#include "AnalyzerCurve.h"
4#include "CustomAudioParameterFloat.h"
5#include "PluginProcessor.h"
6#include <Filter.h>
7#include <Fonts.h>
8#include <JuceHeader.h>
9#include <array>
10
11// extern "C" {
12// size_t add(size_t left, size_t right);
13// typedef struct FFT FFT;
14// }
15
16class EQView : public juce::Component
17{
18 class Handle : public juce::Component
19 {
20 public:
21 static constexpr int handleSize = 20;
22 Handle(Filter::Type type, juce::RangedAudioParameter *bypassParam, juce::RangedAudioParameter *freqParam,
23 juce::RangedAudioParameter *filterOrder, juce::RangedAudioParameter *gainParam = nullptr,
24 juce::RangedAudioParameter *qParam = nullptr);
25
26 void paint(juce::Graphics &g) override;
27 void mouseDown(const juce::MouseEvent &event) override;
28 void mouseDrag(const juce::MouseEvent &event) override;
29 void mouseWheelMove(const juce::MouseEvent &event, const juce::MouseWheelDetails &wheel) override;
30 void updateFrequencyPositionFromParameter(float newValue);
31 void updateGainPositionFromParameter(float newValue);
32 void updateFilerOrderFromParameter(float newValue);
33
34 juce::RangedAudioParameter *mBypassParameter;
35 juce::RangedAudioParameter *mFreqParameter;
36 juce::RangedAudioParameter *mGainParameter;
37 juce::RangedAudioParameter *mQParameter;
38 juce::RangedAudioParameter *mFilterOrder;
39
40 std::unique_ptr<Filter> mFilter;
41
42 private:
43 juce::ComponentDragger dragger;
44 juce::ComponentBoundsConstrainer constrainer;
45
46 std::unique_ptr<juce::ParameterAttachment> mBypassAttachment{nullptr};
47 std::unique_ptr<juce::ParameterAttachment> mFilterOrderAttachment{nullptr};
48 std::unique_ptr<juce::ParameterAttachment> mFreqAttachment{nullptr};
49 std::unique_ptr<juce::ParameterAttachment> mGainAttachment{nullptr};
50 std::unique_ptr<juce::ParameterAttachment> mQAttachment{nullptr};
51
52 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Handle)
53 };
54
55 public:
56 EQView(AudioPluginAudioProcessor &processor, juce::AudioProcessorValueTreeState &parameters);
57 ~EQView() override;
58 void resized() override;
59 void paint(juce::Graphics &g) override;
60
61 void drawGrid(juce::Graphics &g);
62 void drawTextLabels(juce::Graphics &g);
63 void drawVerticalLines(juce::Graphics &g);
64 void drawHorizontalLines(juce::Graphics &g);
65 void drawPlotCurve(juce::Graphics &g);
66 void updateFrequencyResponse();
67 std::vector<std::unique_ptr<Handle>> &getHandles()
68 {
69 return mHandles;
70 }
71
72 std::vector<float> getFrequencies();
73 std::vector<float> getXs(const std::vector<float> &freqs, float left, float width);
74 std::vector<int> getGains();
75
76 juce::Rectangle<int> getRenderArea();
77
78 private:
79 AudioPluginAudioProcessor &mProcessor;
80 juce::AudioProcessorValueTreeState &mParameters;
81 AnalyzerCurve mAnalyzerCurve;
82 juce::Path frequencyResponse;
83 int mSampleRate;
84 juce::Component handleContainer;
85 juce::Font deathMetalFont;
86 static constexpr int reducedSize = 30;
87
88 std::atomic<bool> parameterChanged{false};
89
90 std::vector<std::unique_ptr<Handle>> mHandles;
91
92 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(EQView)
93};
Definition AnalyzerCurve.h:7
Definition PluginProcessor.h:9
Definition EQView.h:17