9#include "sound_engine.h"
16 setSliderStyle(LinearBarVertical);
22 static constexpr float kLineWidthRatio = 0.165f;
23 static constexpr float kFadeRatio = 0.12f;
26 float width = getWidth() - 2.0f * buffer;
27 float height = getHeight() - 4.0f * buffer;
29 float radians = 2.0f * end_radians * y_percent - end_radians;
34 float sin_value = sinf(radians);
35 float cos_value = cosf(radians);
36 float y = 2.0f * buffer + height * 0.5f + sin_value * height * 0.45f;
39 float line_height = cos_value * height * kLineWidthRatio;
41 float distance_from_edge = std::min(y - 2.0f * buffer, height + 2.0f * buffer - y);
42 float alpha = std::max(0.0f, std::min(1.0f, distance_from_edge / (height * kFadeRatio)));
43 g.setColour(fill_color.interpolatedWith(line_color, alpha));
44 float offset = (line_height + round_amount) / 2.0f;
45 g.fillRoundedRectangle(buffer, y - offset, width, std::max(0.0f, line_height + round_amount), round_amount);
47 g.setColour(fill_color);
52 g.fillRoundedRectangle(buffer, y - offset, width, 2.0f * round_amount, round_amount);
57 static constexpr int kNumLines = 6;
58 static constexpr float kRotatePercent = 0.8f;
64 Colour fill_color = background;
68 g.setColour(background);
69 g.fillRoundedRectangle(getLocalBounds().toFloat().reduced(buffer, buffer), round_amount);
71 float t = 1.0f - (getValue() - getMinimum()) / (getMaximum() - getMinimum());
72 t = (t - 0.5f) * kRotatePercent + 0.5f;
73 float ratio_spacing = 1.0f / kNumLines;
76 for (
int i = kNumLines; t + ratio_spacing * i >= 0.5f; --i) {
77 float ratio = t + ratio_spacing * i;
79 paintLine(g, ratio, marker_color, fill_color);
81 paintLine(g, ratio, line_color, fill_color);
85 for (
int i = -kNumLines; t + ratio_spacing * i < 0.5f; ++i) {
86 float ratio = t + ratio_spacing * i;
88 paintLine(g, ratio, marker_color, fill_color);
90 paintLine(g, ratio, line_color, fill_color);
95 erase.addRectangle(getLocalBounds().toFloat());
96 erase.setUsingNonZeroWinding(
false);
97 erase.addRoundedRectangle(getLocalBounds().toFloat().reduced(buffer, buffer), round_amount);
102 shadow.addRoundedRectangle(getLocalBounds().toFloat(), round_amount);
103 shadow.setUsingNonZeroWinding(
false);
104 shadow.addRoundedRectangle(getLocalBounds().toFloat().reduced(buffer, buffer), round_amount);
111 parent_ = findParentComponentOfClass<SynthGuiInterface>();
125 setValue(0.0, sendNotification);
130 pitch_wheel_ = std::make_unique<PitchWheel>();
132 pitch_wheel_->setPopupPlacement(BubbleComponent::above);
134 mod_wheel_ = std::make_unique<ModWheel>();
136 mod_wheel_->setPopupPlacement(BubbleComponent::above);
155 int x_padding = getWidth() * 0.16f;
156 x_padding -= (getWidth() + x_padding) % 2;
157 int wheel_height = getHeight() - 2 * widget_margin;
159 int right1 = (getWidth() - x_padding) / 2;
160 pitch_wheel_->setBounds(x_padding, widget_margin, right1 - x_padding, wheel_height);
161 int x2 = right1 + x_padding;
162 mod_wheel_->setBounds(x2, widget_margin, getWidth() - x_padding - x2, wheel_height);
171 if (parent ==
nullptr)
174 if (changed_slider == mod_wheel_.get())
176 else if (changed_slider == pitch_wheel_.get())
Declares classes for pitch and modulation wheels, and the BendSection container.
BendSection(const String &name)
Constructor for BendSection.
Definition bend_section.cpp:129
void paintBackground(Graphics &g) override
Paints the background of the BendSection.
Definition bend_section.cpp:145
void sliderValueChanged(Slider *changed_slider) override
Called when a slider value changes in the BendSection (pitch or mod wheel).
Definition bend_section.cpp:168
~BendSection()
Destructor.
void resized() override
Resizes and lays out the wheels.
Definition bend_section.cpp:153
A specialized SynthSlider representing a wheel control (pitch or modulation).
Definition bend_section.h:17
ControlWheel(String name)
Constructor for ControlWheel.
Definition bend_section.cpp:13
static constexpr float kBufferWidthRatio
Ratio of width used as a buffer space inside the wheel.
Definition bend_section.h:20
SynthGuiInterface * parent_
Reference to the parent SynthGuiInterface.
Definition bend_section.h:45
void parentHierarchyChanged() override
Called when the component's parent hierarchy changes.
Definition bend_section.cpp:109
void paintLine(Graphics &g, float y_percent, Colour line_color, Colour fill_color)
Paints a line segment representing the wheel position.
Definition bend_section.cpp:21
void paint(Graphics &g) override
Paints the ControlWheel.
Definition bend_section.cpp:56
static constexpr float kContainerRoundAmountRatio
Ratio for the rounded corner of the container.
Definition bend_section.h:24
static constexpr float kWheelRoundAmountRatio
Ratio for the rounded amount of the wheel arc.
Definition bend_section.h:22
ModWheel()
Constructor.
Definition bend_section.cpp:117
void paintToImage(bool paint)
Definition synth_slider.h:93
void mouseUp(const MouseEvent &e) override
Mouse up event for PitchWheel resets the value to 0.
Definition bend_section.cpp:123
PitchWheel()
Constructor.
Definition bend_section.cpp:120
@ kWidgetAccent1
Definition skin.h:171
@ kWidgetPrimary1
Definition skin.h:165
@ kWidgetSecondary1
Definition skin.h:168
@ kShadow
Definition skin.h:142
@ kBody
Definition skin.h:129
@ kKeyboard
Definition skin.h:44
void modWheelGuiChanged(vital::mono_float value)
Called when the mod wheel changes via the GUI or another external source.
Definition synth_base.cpp:80
void pitchWheelGuiChanged(vital::mono_float value)
Called when the pitch wheel changes via the GUI or another external source.
Definition synth_base.cpp:76
An interface class linking the Vital synthesizer backend (SynthBase) with a GUI.
Definition synth_gui_interface.h:56
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
void addSlider(SynthSlider *slider, bool show=true, bool listen=true)
Definition synth_section.cpp:445
void paintOpenGlChildrenBackgrounds(Graphics &g)
Paints the backgrounds for all OpenGL child components.
Definition synth_section.cpp:267
virtual void resized() override
Called when the component is resized. Arranges layout of child components.
Definition synth_section.cpp:35
virtual void paintBody(Graphics &g, Rectangle< int > bounds)
Paints the body background within given bounds.
Definition synth_section.cpp:165
void paintKnobShadows(Graphics &g)
Paints knob shadows for all sliders.
Definition synth_section.cpp:253
virtual void paintBorder(Graphics &g, Rectangle< int > bounds)
Paints the border around given bounds.
Definition synth_section.cpp:170
virtual void sliderValueChanged(Slider *moved_slider) override
Called when a slider value changes. Updates the synth parameter accordingly.
Definition synth_section.cpp:391
void setSkinOverride(Skin::SectionOverride skin_override)
Definition synth_section.h:303
float getWidgetMargin()
Definition synth_section.cpp:676
A specialized slider with extended functionality for modulation, parameter control,...
Definition synth_slider.h:314
virtual void parentHierarchyChanged() override
Called when the parent hierarchy changes, updates references to synthesizer.
Definition synth_slider.cpp:499
void setSensitivity(double sensitivity)
Definition synth_slider.h:542
virtual void mouseUp(const MouseEvent &e) override
Definition synth_slider.cpp:302
constexpr mono_float kPi
Pi constant.
Definition common.h:36
Declares the SynthSlider and related classes, providing various slider styles and functionality in th...