150 lines
3.4 KiB
C++
150 lines
3.4 KiB
C++
#pragma once
|
|
|
|
#include <JuceHeader.h>
|
|
#include "PluginProcessor.h"
|
|
|
|
class CrilleBassStripAudioProcessorEditor final
|
|
: public juce::AudioProcessorEditor,
|
|
private juce::Timer
|
|
{
|
|
public:
|
|
explicit CrilleBassStripAudioProcessorEditor(
|
|
CrilleBassStripAudioProcessor&);
|
|
|
|
~CrilleBassStripAudioProcessorEditor() override = default;
|
|
|
|
void paint(juce::Graphics&) override;
|
|
void resized() override;
|
|
|
|
private:
|
|
class LevelMeter final : public juce::Component
|
|
{
|
|
public:
|
|
enum class Mode
|
|
{
|
|
inputLevel,
|
|
gainReduction
|
|
};
|
|
|
|
explicit LevelMeter(Mode meterMode);
|
|
|
|
void setLevel(float newLevelDb);
|
|
void setThreshold(float newThresholdDb);
|
|
void paint(juce::Graphics&) override;
|
|
|
|
private:
|
|
Mode mode;
|
|
float displayedDb = -80.0f;
|
|
float thresholdDb = -80.0f;
|
|
};
|
|
|
|
class SectionToggleButton final : public juce::ToggleButton
|
|
{
|
|
public:
|
|
SectionToggleButton(
|
|
const juce::String& sectionName,
|
|
juce::Colour activeColour);
|
|
|
|
void paintButton(
|
|
juce::Graphics& g,
|
|
bool shouldDrawButtonAsHighlighted,
|
|
bool shouldDrawButtonAsDown) override;
|
|
|
|
private:
|
|
juce::Colour sectionColour;
|
|
};
|
|
|
|
struct Knob
|
|
{
|
|
juce::Slider slider;
|
|
juce::Label label;
|
|
};
|
|
|
|
CrilleBassStripAudioProcessor& processor;
|
|
|
|
std::vector<std::unique_ptr<Knob>> knobs;
|
|
|
|
std::vector<std::unique_ptr<
|
|
juce::AudioProcessorValueTreeState::SliderAttachment>>
|
|
attachments;
|
|
|
|
juce::ToggleButton downTuneButton;
|
|
|
|
std::unique_ptr<
|
|
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
|
downTuneAttachment;
|
|
|
|
SectionToggleButton gateToggleButton {
|
|
"NOISE GATE",
|
|
juce::Colour(0xffe5a536)
|
|
};
|
|
|
|
SectionToggleButton compressorToggleButton {
|
|
"COMPRESSOR",
|
|
juce::Colour(0xffe5a536)
|
|
};
|
|
|
|
SectionToggleButton distortionToggleButton {
|
|
"DISTORTION",
|
|
juce::Colour(0xffd26b4f)
|
|
};
|
|
|
|
SectionToggleButton eqToggleButton {
|
|
"EQUALIZER",
|
|
juce::Colour(0xffe5a536)
|
|
};
|
|
|
|
std::unique_ptr<
|
|
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
|
gateToggleAttachment;
|
|
|
|
std::unique_ptr<
|
|
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
|
compressorToggleAttachment;
|
|
|
|
std::unique_ptr<
|
|
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
|
distortionToggleAttachment;
|
|
|
|
std::unique_ptr<
|
|
juce::AudioProcessorValueTreeState::ButtonAttachment>
|
|
eqToggleAttachment;
|
|
|
|
LevelMeter gateInputMeter {
|
|
LevelMeter::Mode::inputLevel
|
|
};
|
|
|
|
LevelMeter compressorInputMeter {
|
|
LevelMeter::Mode::inputLevel
|
|
};
|
|
|
|
LevelMeter compressorReductionMeter {
|
|
LevelMeter::Mode::gainReduction
|
|
};
|
|
|
|
float smoothedGateDb = -80.0f;
|
|
float smoothedCompressorDb = -80.0f;
|
|
float smoothedReductionDb = 0.0f;
|
|
|
|
void addKnob(
|
|
const juce::String& parameter,
|
|
const juce::String& caption);
|
|
|
|
void timerCallback() override;
|
|
|
|
void updateSectionStates();
|
|
|
|
void setKnobSectionEnabled(
|
|
int firstKnob,
|
|
int numberOfKnobs,
|
|
bool enabled);
|
|
|
|
static float smoothMeter(
|
|
float current,
|
|
float target,
|
|
float attack,
|
|
float release);
|
|
|
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
|
|
CrilleBassStripAudioProcessorEditor)
|
|
}; |