10#include "sound_engine.h"
16 Path bufferPath(
const Path& path) {
17 static constexpr float kBuffer = 0.3f;
18 Rectangle<float> bounds = path.getBounds();
21 float top = bounds.getY() - kBuffer;
22 float bottom = bounds.getBottom() + kBuffer;
23 result.addLineSegment(Line<float>(bounds.getX(), top, bounds.getX(), top), 0.1f);
24 result.addLineSegment(Line<float>(bounds.getX(), bottom, bounds.getX(), bottom), 0.1f);
32 low_mode_ = std::make_unique<OpenGlShapeButton>(
"eq_low_mode");
33 low_mode_->useOnColors(
true);
34 low_mode_->setClickingTogglesState(
true);
36 low_mode_->addListener(
this);
39 band_mode_ = std::make_unique<OpenGlShapeButton>(
"eq_band_mode");
40 band_mode_->useOnColors(
true);
41 band_mode_->setClickingTogglesState(
true);
43 band_mode_->addListener(
this);
46 high_mode_ = std::make_unique<OpenGlShapeButton>(
"eq_high_mode");
47 high_mode_->useOnColors(
true);
48 high_mode_->setClickingTogglesState(
true);
50 high_mode_->addListener(
this);
53 low_cutoff_ = std::make_unique<SynthSlider>(
"eq_low_cutoff");
55 low_cutoff_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
58 low_resonance_ = std::make_unique<SynthSlider>(
"eq_low_resonance");
60 low_resonance_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
62 low_gain_ = std::make_unique<SynthSlider>(
"eq_low_gain");
64 low_gain_->setBipolar();
65 low_gain_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
67 band_cutoff_ = std::make_unique<SynthSlider>(
"eq_band_cutoff");
69 band_cutoff_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
72 band_resonance_ = std::make_unique<SynthSlider>(
"eq_band_resonance");
74 band_resonance_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
76 band_gain_ = std::make_unique<SynthSlider>(
"eq_band_gain");
78 band_gain_->setBipolar();
79 band_gain_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
81 high_cutoff_ = std::make_unique<SynthSlider>(
"eq_high_cutoff");
83 high_cutoff_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
86 high_resonance_ = std::make_unique<SynthSlider>(
"eq_high_resonance");
88 high_resonance_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
90 high_gain_ = std::make_unique<SynthSlider>(
"eq_high_gain");
92 high_gain_->setBipolar();
93 high_gain_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
95 spectrogram_ = std::make_unique<Spectrogram>();
98 spectrogram_->setMinFrequency(min_frequency);
100 spectrogram_->setMaxFrequency(max_frequency);
101 spectrogram_->setInterceptsMouseClicks(
false,
false);
102 spectrogram_->setFill(
true);
104 eq_response_ = std::make_unique<EqualizerResponse>();
105 eq_response_->initEq(mono_modulations);
107 eq_response_->setLowSliders(low_cutoff_.get(), low_resonance_.get(), low_gain_.get());
108 eq_response_->setBandSliders(band_cutoff_.get(), band_resonance_.get(), band_gain_.get());
109 eq_response_->setHighSliders(high_cutoff_.get(), high_resonance_.get(), high_gain_.get());
110 eq_response_->addListener(
this);
112 on_ = std::make_unique<SynthButton>(
"eq_on");
115 selected_band_ = std::make_unique<TabSelector>(
"selected_band");
116 addAndMakeVisible(selected_band_.get());
118 selected_band_->setSliderStyle(Slider::LinearBar);
119 selected_band_->setRange(0, 2);
120 selected_band_->addListener(
this);
121 selected_band_->setNames({
"LOW",
"BAND",
"HIGH"});
122 selected_band_->setFontHeightPercent(0.4f);
123 selected_band_->setScrollWheelEnabled(
false);
137 Colour color = background.overlaidWith(lighten);
138 color = color.withAlpha(1.0f);
143 spectrogram_->setLineWidth(2.5f);
152 g.fillRoundedRectangle(low_mode_->getBounds().toFloat(), button_rounding);
153 g.fillRoundedRectangle(band_mode_->getBounds().toFloat(), button_rounding);
154 g.fillRoundedRectangle(high_mode_->getBounds().toFloat(), button_rounding);
159 Rectangle<int> bounds = getLocalBounds().withLeft(title_width);
162 spectrogram_->setBounds(widget_bounds.reduced(0, widget_margin));
163 eq_response_->setBounds(spectrogram_->getBounds());
169 int knob_y = getHeight() - section_height;
170 int button_y = widget_margin;
172 placeKnobsInArea(Rectangle<int>(knobs_area.getX(), knob_y, knobs_area.getWidth(), section_height),
173 { low_gain_.get(), low_cutoff_.get(), low_resonance_.get() });
175 band_cutoff_->setBounds(low_cutoff_->getBounds());
176 band_resonance_->setBounds(low_resonance_->getBounds());
177 band_gain_->setBounds(low_gain_->getBounds());
179 high_cutoff_->setBounds(low_cutoff_->getBounds());
180 high_resonance_->setBounds(low_resonance_->getBounds());
181 high_gain_->setBounds(low_gain_->getBounds());
183 low_mode_->setBounds(low_gain_->getX(), button_y, low_gain_->getWidth(), button_height);
184 band_mode_->setBounds(low_cutoff_->getX(), button_y, low_cutoff_->getWidth(), button_height);
185 high_mode_->setBounds(low_resonance_->getX(), button_y, low_resonance_->getWidth(), button_height);
187 int selected_y = low_mode_->getBottom() + widget_margin;
188 int selected_height = knob_y - selected_y + widget_margin;
189 selected_band_->setBounds(title_width + widget_margin, selected_y,
190 knobs_area.getWidth() - 2 * widget_margin, selected_height);
196 eq_response_->setActive(active);
197 selected_band_->setActive(active);
203 selected_band_->setValue(0.0, dontSendNotification);
204 selected_band_->redoImage();
205 low_cutoff_->setVisible(
true);
206 low_resonance_->setVisible(
true);
207 low_gain_->setVisible(
true);
209 band_cutoff_->setVisible(
false);
210 band_resonance_->setVisible(
false);
211 band_gain_->setVisible(
false);
213 high_cutoff_->setVisible(
false);
214 high_resonance_->setVisible(
false);
215 high_gain_->setVisible(
false);
219 selected_band_->setValue(1.0, dontSendNotification);
220 selected_band_->redoImage();
221 low_cutoff_->setVisible(
false);
222 low_resonance_->setVisible(
false);
223 low_gain_->setVisible(
false);
225 band_cutoff_->setVisible(
true);
226 band_resonance_->setVisible(
true);
227 band_gain_->setVisible(
true);
229 high_cutoff_->setVisible(
false);
230 high_resonance_->setVisible(
false);
231 high_gain_->setVisible(
false);
235 selected_band_->setValue(2.0, dontSendNotification);
236 selected_band_->redoImage();
237 low_cutoff_->setVisible(
false);
238 low_resonance_->setVisible(
false);
239 low_gain_->setVisible(
false);
241 band_cutoff_->setVisible(
false);
242 band_resonance_->setVisible(
false);
243 band_gain_->setVisible(
false);
245 high_cutoff_->setVisible(
true);
246 high_resonance_->setVisible(
true);
247 high_gain_->setVisible(
true);
251 if (slider == selected_band_.get()) {
252 if (selected_band_->getValue() == 0)
254 else if (selected_band_->getValue() == 1)
256 else if (selected_band_->getValue() == 2)
259 eq_response_->setSelectedBand(selected_band_->getValue());
267 if (button == low_mode_.get()) {
268 eq_response_->setHighPass(low_mode_->getToggleState());
269 selected_band_->setValue(0);
271 else if (button == band_mode_.get()) {
272 eq_response_->setNotch(band_mode_->getToggleState());
273 selected_band_->setValue(1);
275 else if (button == high_mode_.get()) {
276 eq_response_->setLowPass(high_mode_->getToggleState());
277 selected_band_->setValue(2);
283 selected_band_->setScrollWheelEnabled(enabled);
288 low_gain_->setActive(
isActive() && !low_mode_->getToggleState());
289 band_gain_->setActive(
isActive() && !band_mode_->getToggleState());
290 high_gain_->setActive(
isActive() && !high_mode_->getToggleState());
297 parent_ = findParentComponentOfClass<SynthGuiInterface>();
306 if (oversampling_amount >= 1)
307 spectrogram_->setOversampleAmount(oversampling_amount);
void midBandSelected() override
Called when the mid band is selected in the EQ response.
Definition equalizer_section.cpp:218
EqualizerSection(String name, const vital::output_map &mono_modulations)
Definition equalizer_section.cpp:29
void parentHierarchyChanged() override
Called when the parent hierarchy changes, used to set up spectrogram memory.
Definition equalizer_section.cpp:293
void renderOpenGlComponents(OpenGlWrapper &open_gl, bool animate) override
Definition equalizer_section.cpp:303
void resized() override
Resizes and lays out child components (filter sliders, spectrogram, etc.).
Definition equalizer_section.cpp:157
void sliderValueChanged(Slider *slider) override
Definition equalizer_section.cpp:250
void paintBackground(Graphics &g) override
Definition equalizer_section.cpp:132
void setGainActive()
Sets the gain sliders active or inactive based on the current mode and active state.
Definition equalizer_section.cpp:287
void setActive(bool active) override
Definition equalizer_section.cpp:195
virtual ~EqualizerSection()
Destructor.
Definition equalizer_section.cpp:130
void highBandSelected() override
Called when the high band is selected in the EQ response.
Definition equalizer_section.cpp:234
void buttonClicked(Button *button) override
Definition equalizer_section.cpp:265
void lowBandSelected() override
Called when the low band is selected in the EQ response.
Definition equalizer_section.cpp:202
void setScrollWheelEnabled(bool enabled) override
Definition equalizer_section.cpp:282
static Path highPass()
Definition paths.h:853
static Path notch()
Definition paths.h:949
static Path lowPass(float line_thickness=0.1f)
Definition paths.h:842
@ kWidgetMargin
Definition skin.h:103
@ kLabelBackgroundRounding
Definition skin.h:74
@ kWidgetPrimary2
Definition skin.h:166
@ kWidgetPrimary1
Definition skin.h:165
@ kWidgetBackground
Definition skin.h:173
@ kWidgetSecondary1
Definition skin.h:168
@ kLightenScreen
Definition skin.h:141
@ kTextComponentBackground
Definition skin.h:147
@ kWidgetSecondary2
Definition skin.h:169
@ kEqualizer
Definition skin.h:50
const vital::StereoMemory * getEqualizerMemory()
Retrieves memory used for equalizer visualization, if available.
Definition synth_base.cpp:724
vital::SoundEngine * getEngine()
Returns a pointer to the SoundEngine used for audio and modulation processing.
Definition synth_base.h:484
SynthBase * getSynth()
Returns the SynthBase instance this interface is managing.
Definition synth_gui_interface.h:85
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193
Rectangle< int > getDividedAreaBuffered(Rectangle< int > full_area, int num_sections, int section, int buffer)
Divides an area into equal sections with buffering, returns the specified section.
Definition synth_section.cpp:776
virtual void buttonClicked(Button *clicked_button) override
Called when a button is clicked. Updates the synth parameter accordingly.
Definition synth_section.cpp:398
virtual void renderOpenGlComponents(OpenGlWrapper &open_gl, bool animate)
Renders all OpenGL components in this section and sub-sections.
Definition synth_section.cpp:357
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 animate(bool animate)
Triggers animation state change in sub-sections if needed.
Definition synth_section.cpp:822
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
void setLabelFont(Graphics &g)
Sets the Graphics context font and color for labels.
Definition synth_section.cpp:740
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
bool isActive() const
Checks if the section is currently active.
Definition synth_section.h:683
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
float getTextComponentHeight()
Definition synth_section.cpp:652
Rectangle< int > getDividedAreaUnbuffered(Rectangle< int > full_area, int num_sections, int section, int buffer)
Divides an area into equal sections without extra buffering, returns the specified section.
Definition synth_section.cpp:768
void setSliderHasHzAlternateDisplay(SynthSlider *slider)
Definition synth_section.cpp:410
float getTitleWidth()
Definition synth_section.cpp:629
virtual void setScrollWheelEnabled(bool enabled)
Enables or disables scroll wheel support for this section and sub-sections.
Definition synth_section.cpp:481
void setSkinOverride(Skin::SectionOverride skin_override)
Definition synth_section.h:303
force_inline int getOversamplingAmount() const
Retrieves the current oversampling factor (e.g., 1, 2, 4).
Definition sound_engine.h:395
Declares the EqualizerSection class, providing a UI for a 3-band equalizer with adjustable modes and ...
force_inline poly_float midiNoteToFrequency(poly_float value)
Converts a MIDI note to a frequency (vectorized).
Definition poly_utils.h:123
std::map< std::string, Output * > output_map
Maps parameter names to Output pointers, representing output signals from various modules.
Definition synth_types.h:229
A helper struct containing references to OpenGL context, shaders, and display scale.
Definition shaders.h:174
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.