Vital
Loading...
Searching...
No Matches
reverb_section.cpp
Go to the documentation of this file.
1#include "reverb_section.h"
2
3#include "skin.h"
4#include "fonts.h"
5#include "synth_button.h"
6#include "synth_slider.h"
7#include "tab_selector.h"
8
9ReverbSection::ReverbSection(String name, const vital::output_map& mono_modulations) : SynthSection(name) {
10 dry_wet_ = std::make_unique<SynthSlider>("reverb_dry_wet");
11 addSlider(dry_wet_.get());
12 dry_wet_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
13
14 high_pre_cutoff_ = std::make_unique<SynthSlider>("reverb_pre_high_cutoff");
15 addSlider(high_pre_cutoff_.get());
16 high_pre_cutoff_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
17 setSliderHasHzAlternateDisplay(high_pre_cutoff_.get());
18
19 chorus_frequency_ = std::make_unique<SynthSlider>("reverb_chorus_frequency");
20 addSlider(chorus_frequency_.get());
21 chorus_frequency_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
22
23 low_gain_ = std::make_unique<SynthSlider>("reverb_low_shelf_gain");
24 addSlider(low_gain_.get());
25 low_gain_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
26
27 high_gain_ = std::make_unique<SynthSlider>("reverb_high_shelf_gain");
28 addSlider(high_gain_.get());
29 high_gain_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
30
31 decay_time_ = std::make_unique<SynthSlider>("reverb_decay_time");
32 addSlider(decay_time_.get());
33 decay_time_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
34
35 low_pre_cutoff_ = std::make_unique<SynthSlider>("reverb_pre_low_cutoff");
36 addSlider(low_pre_cutoff_.get());
37 low_pre_cutoff_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
38 setSliderHasHzAlternateDisplay(low_pre_cutoff_.get());
39
40 low_cutoff_ = std::make_unique<SynthSlider>("reverb_low_shelf_cutoff");
41 addSlider(low_cutoff_.get());
42 low_cutoff_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
43 setSliderHasHzAlternateDisplay(low_cutoff_.get());
44
45 high_cutoff_ = std::make_unique<SynthSlider>("reverb_high_shelf_cutoff");
46 addSlider(high_cutoff_.get());
47 high_cutoff_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
48 setSliderHasHzAlternateDisplay(high_cutoff_.get());
49
50 chorus_amount_ = std::make_unique<SynthSlider>("reverb_chorus_amount");
51 addSlider(chorus_amount_.get());
52 chorus_amount_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
53
54 delay_ = std::make_unique<SynthSlider>("reverb_delay");
55 addSlider(delay_.get());
56 delay_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
57
58 size_ = std::make_unique<SynthSlider>("reverb_size");
59 addSlider(size_.get());
60 size_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
61
62 feedback_eq_response_ = std::make_unique<EqualizerResponse>();
63 feedback_eq_response_->setDbBufferRatio(kFeedbackFilterBuffer);
64 feedback_eq_response_->initReverb(mono_modulations);
65 feedback_eq_response_->setLowSliders(low_cutoff_.get(), nullptr, low_gain_.get());
66 feedback_eq_response_->setHighSliders(high_cutoff_.get(), nullptr, high_gain_.get());
67 feedback_eq_response_->setDrawFrequencyLines(false);
68 addAndMakeVisible(feedback_eq_response_.get());
69 addOpenGlComponent(feedback_eq_response_.get());
70 feedback_eq_response_->addListener(this);
71
72 selected_eq_band_ = std::make_unique<TabSelector>("selected_band");
73 addAndMakeVisible(selected_eq_band_.get());
74 addOpenGlComponent(selected_eq_band_->getImageComponent());
75 selected_eq_band_->setSliderStyle(Slider::LinearBar);
76 selected_eq_band_->setRange(0, 1);
77 selected_eq_band_->addListener(this);
78 selected_eq_band_->setNames({"LOW", "HIGH"});
79 selected_eq_band_->setFontHeightPercent(0.4f);
80 selected_eq_band_->setScrollWheelEnabled(false);
81
82 on_ = std::make_unique<SynthButton>("reverb_on");
83 addButton(on_.get());
84 setActivator(on_.get());
87}
88
90
93
94 g.setColour(findColour(Skin::kBodyText, true));
95 g.setFont(Fonts::instance()->proportional_regular().withPointHeight(size_ratio_ * 10.0f));
96
97 drawLabelForComponent(g, TRANS("TIME"), decay_time_.get());
98 drawLabelForComponent(g, TRANS("PRE LOW CUT"), low_pre_cutoff_.get());
99 drawLabelForComponent(g, TRANS("PRE HIGH CUT"), high_pre_cutoff_.get());
100 drawLabelForComponent(g, TRANS("CUTOFF"), low_cutoff_.get());
101 drawLabelForComponent(g, TRANS("GAIN"), low_gain_.get());
102 drawLabelForComponent(g, TRANS("CHORUS AMT"), chorus_amount_.get());
103 drawLabelForComponent(g, TRANS("CHORUS FRQ"), chorus_frequency_.get());
104 drawLabelForComponent(g, TRANS("DELAY"), delay_.get());
105 drawLabelForComponent(g, TRANS("SIZE"), size_.get());
106 drawLabelForComponent(g, TRANS("MIX"), dry_wet_.get());
107}
108
110 int title_width = getTitleWidth();
111 int widget_margin = findValue(Skin::kWidgetMargin);
112 int eq_width = getHeight() - 2 * widget_margin;
113 float feedback_widget_x = (getWidth() - title_width - eq_width - 2 * widget_margin) / 5.0f +
114 title_width + widget_margin;
115 int section_height = getKnobSectionHeight();
116 int widget_rounding = findValue(Skin::kWidgetRoundedCorner);
117 int band_height = kFeedbackFilterBuffer * 0.5f * eq_width;
118
119 int selected_x = feedback_widget_x + widget_rounding;
120 int selected_width = eq_width - 2 * widget_rounding;
121 selected_eq_band_->setBounds(selected_x, widget_margin, selected_width, band_height);
122 feedback_eq_response_->setBounds(feedback_widget_x, widget_margin, eq_width, eq_width);
123
124 int pre_cutoff_x = title_width + widget_margin;
125 int pre_cutoff_width = feedback_widget_x - pre_cutoff_x - widget_margin;
126 int knob_y2 = section_height - widget_margin;
127
128 low_pre_cutoff_->setBounds(pre_cutoff_x, 0, pre_cutoff_width, section_height - widget_margin);
129 high_pre_cutoff_->setBounds(pre_cutoff_x, knob_y2, pre_cutoff_width, section_height - widget_margin);
130
131 int knobs_x = feedback_widget_x + eq_width;
132 int knobs_width = getWidth() - knobs_x;
133
134 placeKnobsInArea(Rectangle<int>(knobs_x, 0, knobs_width, section_height),
135 { low_cutoff_.get(), chorus_amount_.get(), delay_.get(), dry_wet_.get() });
136
137 placeKnobsInArea(Rectangle<int>(knobs_x, knob_y2, knobs_width, section_height),
138 { low_gain_.get(), chorus_frequency_.get(), size_.get(), decay_time_.get() });
139
140 high_cutoff_->setBounds(low_cutoff_->getBounds());
141 high_gain_->setBounds(low_gain_->getBounds());
142
144}
145
146void ReverbSection::setActive(bool active) {
147 feedback_eq_response_->setActive(active);
148 selected_eq_band_->setActive(active);
150}
151
153 selected_eq_band_->setValue(0.0, dontSendNotification);
154 selected_eq_band_->redoImage();
155 low_cutoff_->setVisible(true);
156 low_gain_->setVisible(true);
157
158 high_cutoff_->setVisible(false);
159 high_gain_->setVisible(false);
160}
161
163 selected_eq_band_->setValue(1.0, dontSendNotification);
164 selected_eq_band_->redoImage();
165 low_cutoff_->setVisible(false);
166 low_gain_->setVisible(false);
167
168 high_cutoff_->setVisible(true);
169 high_gain_->setVisible(true);
170}
171
173 if (slider == selected_eq_band_.get()) {
174 if (selected_eq_band_->getValue() == 0.0f)
176 else
178
179 feedback_eq_response_->setSelectedBand(selected_eq_band_->getValue() * 2.0f);
180 }
181 else
183}
static Fonts * instance()
Gets the singleton instance of the Fonts class.
Definition fonts.h:52
void sliderValueChanged(Slider *slider) override
Called when a slider's value changes.
Definition reverb_section.cpp:172
~ReverbSection()
Destructor.
Definition reverb_section.cpp:89
void resized() override
Called when the component is resized. Arranges the sliders, buttons, and EQ visualization.
Definition reverb_section.cpp:109
void highBandSelected() override
Called when the high EQ band is selected in the EqualizerResponse.
Definition reverb_section.cpp:162
static constexpr float kFeedbackFilterBuffer
Used to scale the feedback filter EQ buffer.
Definition reverb_section.h:20
void setActive(bool active) override
Sets the active state of this section.
Definition reverb_section.cpp:146
void lowBandSelected() override
Called when the low EQ band is selected in the EqualizerResponse.
Definition reverb_section.cpp:152
void paintBackground(Graphics &g) override
Paints the reverb section background, labels, and any custom UI elements.
Definition reverb_section.cpp:91
ReverbSection(String name, const vital::output_map &mono_modulations)
Constructs a ReverbSection.
Definition reverb_section.cpp:9
@ kWidgetMargin
Definition skin.h:103
@ kWidgetRoundedCorner
Definition skin.h:104
@ kBodyText
Definition skin.h:133
@ kReverb
Definition skin.h:54
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193
void placeKnobsInArea(Rectangle< int > area, std::vector< Component * > knobs)
Definition synth_section.cpp:601
void addSlider(SynthSlider *slider, bool show=true, bool listen=true)
Definition synth_section.cpp:445
virtual void resized() override
Called when the component is resized. Arranges layout of child components.
Definition synth_section.cpp:35
virtual void setActive(bool active)
Sets the active state of this section and sub-sections.
Definition synth_section.cpp:806
void drawLabelForComponent(Graphics &g, String text, Component *component, bool text_component=false)
Draws a label for a given component.
Definition synth_section.h:548
float size_ratio_
Definition synth_section.h:821
void addButton(OpenGlToggleButton *button, bool show=true)
Definition synth_section.cpp:428
float findValue(Skin::ValueId value_id) const
Finds a value in the skin overrides or from the parent if not found locally.
Definition synth_section.cpp:18
virtual void paintBackground(Graphics &g)
Paints the background of the section. Calls paintContainer, heading, knobs, children.
Definition synth_section.cpp:77
float getKnobSectionHeight()
Definition synth_section.cpp:633
void setActivator(SynthButton *activator)
Definition synth_section.cpp:504
void addOpenGlComponent(OpenGlComponent *open_gl_component, bool to_beginning=false)
Definition synth_section.cpp:489
virtual void sliderValueChanged(Slider *moved_slider) override
Called when a slider value changes. Updates the synth parameter accordingly.
Definition synth_section.cpp:391
void setSliderHasHzAlternateDisplay(SynthSlider *slider)
Definition synth_section.cpp:410
float getTitleWidth()
Definition synth_section.cpp:629
void setSkinOverride(Skin::SectionOverride skin_override)
Definition synth_section.h:303
std::map< std::string, Output * > output_map
Maps parameter names to Output pointers, representing output signals from various modules.
Definition synth_types.h:229
Declares classes for OpenGL-based buttons used in the Vital synth UI.
Declares the SynthSlider and related classes, providing various slider styles and functionality in th...
Declares the TabSelector class, a slider-based UI component for selecting tabs.