24 oscillator_active_ =
nullptr;
28 midi_track_ = std::make_unique<SynthButton>(
"osc_" + number +
"_midi_track");
31 midi_track_->setButtonText(
"NOTE TRACK");
33 smooth_interpolation_ = std::make_unique<SynthButton>(
"osc_" + number +
"_smooth_interpolation");
36 smooth_interpolation_->setButtonText(
"HI-RES WAVETABLE");
53 g.fillRoundedRectangle(midi_track_->getBounds().toFloat(), rounding);
54 g.fillRoundedRectangle(smooth_interpolation_->getBounds().toFloat(), rounding);
74 int x = title_width + widget_margin;
75 int width = getWidth() - x - widget_margin;
78 midi_track_->setBounds(x, widget_margin, width, section_height - 2 * widget_margin);
80 int smooth_y = midi_track_->getBottom() + widget_margin;
81 smooth_interpolation_->setBounds(x, smooth_y, width, getHeight() - smooth_y - widget_margin);
91 if (oscillator_active_)
92 setActive(oscillator_active_->getToggleState());
100 if (clicked_button == oscillator_active_)
101 setActive(oscillator_active_->getToggleState());
111 oscillator_active_ = oscillator->
activator();
112 oscillator_active_->addListener(
this);
113 setActive(oscillator_active_->getToggleState());
118 ToggleButton* oscillator_active_;
120 std::unique_ptr<SynthButton> midi_track_;
121 std::unique_ptr<SynthButton> smooth_interpolation_;
143 std::string number = std::to_string(index);
146 std::string voices_name =
"osc_" + number +
"_unison_voices";
148 mono_modulations.at(voices_name),
149 poly_modulations.at(voices_name)
152 std::string wave_frame_name =
"osc_" + number +
"_wave_frame";
153 wave_frame_outputs_ = {
154 mono_modulations.at(wave_frame_name),
155 poly_modulations.at(wave_frame_name)
158 std::string spectral_morph_name =
"osc_" + number +
"_spectral_morph_amount";
159 spectral_morph_outputs_ = {
160 mono_modulations.at(spectral_morph_name),
161 poly_modulations.at(spectral_morph_name)
164 std::string distortion_name =
"osc_" + number +
"_distortion_amount";
165 distortion_outputs_ = {
166 mono_modulations.at(distortion_name),
167 poly_modulations.at(distortion_name)
170 std::string table_spread_name =
"osc_" + number +
"_frame_spread";
171 table_spread_outputs_ = {
172 mono_modulations.at(table_spread_name),
173 poly_modulations.at(table_spread_name)
176 std::string spectral_spread_name =
"osc_" + number +
"_spectral_morph_spread";
177 spectral_spread_outputs_ = {
178 mono_modulations.at(spectral_spread_name),
179 poly_modulations.at(spectral_spread_name)
182 std::string distortion_spread_name =
"osc_" + number +
"_distortion_spread";
183 distortion_spread_outputs_ = {
184 mono_modulations.at(distortion_spread_name),
185 poly_modulations.at(distortion_spread_name)
188 voices_slider_ =
nullptr;
190 wave_frame_slider_ =
nullptr;
191 spectral_morph_slider_ =
nullptr;
192 distortion_slider_ =
nullptr;
194 table_spread_slider_ =
nullptr;
195 spectral_spread_slider_ =
nullptr;
196 distortion_spread_slider_ =
nullptr;
250 if (!outputs.first->owner->enabled() || !animate)
251 return default_value;
252 return outputs.first->trigger_value + outputs.second->trigger_value;
273 if (voices_slider_ ==
nullptr)
276 int voices =
getOutputsTotal(voices_outputs_, voices_slider_->getValue(), animate)[0];
277 voices = std::max(voices, 0);
286 table_spread_slider_->getValue(), animate);
288 spectral_spread_slider_->getValue(), animate);
290 distortion_spread_slider_->getValue(), animate);
296 float height = (2.0f - height_buffer) /
kNumSpreads - height_buffer;
297 float y = height_buffer - 1.0f;
305 y += height + height_buffer;
309 float mult = 2.0f - 2.0f * buffer;
310 float offset = -1.0f + buffer - 1.0f / getWidth();
312 voices += voices % 2;
313 for (
int i = 0; i < voices; i += 2) {
314 float t = 2.0f * i / (voices - 2.0f);
320 setX(i, voice_frame[0] * mult + offset);
321 setX(i + 1, voice_frame[1] * mult + offset);
333 setX(start + i, -2.0f);
350 std::pair<vital::Output*, vital::Output*> voices_outputs_;
352 std::pair<vital::Output*, vital::Output*> wave_frame_outputs_;
353 std::pair<vital::Output*, vital::Output*> spectral_morph_outputs_;
354 std::pair<vital::Output*, vital::Output*> distortion_outputs_;
356 std::pair<vital::Output*, vital::Output*> table_spread_outputs_;
357 std::pair<vital::Output*, vital::Output*> spectral_spread_outputs_;
358 std::pair<vital::Output*, vital::Output*> distortion_spread_outputs_;
376 SynthSection(String(
"OSC ") + String(index) +
" UNISON"), index_(index) {
378 voices_slider_ =
nullptr;
379 oscillator_active_ =
nullptr;
381 String number(index);
383 spectral_unison_ = std::make_unique<SynthButton>(
"osc_" + number +
"_spectral_unison");
386 spectral_unison_->setButtonText(
"SPECTRAL UNISON");
388 stack_style_ = std::make_unique<TextSelector>(
"osc_" + number +
"_stack_style");
390 stack_style_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
394 blend_ = std::make_unique<SynthSlider>(
"osc_" + number +
"_unison_blend");
396 blend_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
398 detune_range_ = std::make_unique<SynthSlider>(
"osc_" + number +
"_detune_range");
400 detune_range_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
403 frame_spread_ = std::make_unique<SynthSlider>(
"osc_" + number +
"_frame_spread");
405 frame_spread_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
406 frame_spread_->setBipolar(
true);
408 distortion_spread_ = std::make_unique<SynthSlider>(
"osc_" + number +
"_distortion_spread");
410 distortion_spread_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
411 distortion_spread_->setBipolar(
true);
413 spectral_morph_spread_ = std::make_unique<SynthSlider>(
"osc_" + number +
"_spectral_morph_spread");
415 spectral_morph_spread_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
416 spectral_morph_spread_->setBipolar(
true);
418 spread_visualizer_ = std::make_unique<SpreadVisualizer>(index, mono_modulations, poly_modulations);
420 spread_visualizer_->setTableSpreadSlider(frame_spread_.get());
421 spread_visualizer_->setSpectralSpreadSlider(spectral_morph_spread_.get());
422 spread_visualizer_->setDistortionSpreadSlider(distortion_spread_.get());
424 stereo_spread_ = std::make_unique<SynthSlider>(
"osc_" + number +
"_stereo_spread");
426 stereo_spread_->setSliderStyle(Slider::RotaryHorizontalVerticalDrag);
466 static constexpr float kTextComponentWidthRatio = 0.23f;
473 int text_width = getWidth() * kTextComponentWidthRatio - 2 * widget_margin;
474 int text_height = knob_section_height - 2 * widget_margin;
475 stack_style_->setBounds(title_width + widget_margin, widget_margin, text_width, text_height);
476 detune_range_->setBounds(title_width + widget_margin, knob_section_height, text_width, text_height);
478 int controls_x = detune_range_->getRight();
479 placeKnobsInArea(Rectangle<int>(controls_x, 0, getWidth() - controls_x, knob_section_height),
480 { blend_.get(),
nullptr,
nullptr,
nullptr });
481 stack_style_->setBounds(stack_style_->getBounds().withTop(widget_margin));
483 int knob_y2 = getHeight() - knob_section_height;
484 placeKnobsInArea(Rectangle<int>(controls_x, knob_y2, getWidth() - controls_x, knob_section_height),
485 { stereo_spread_.get(), frame_spread_.get(),
486 spectral_morph_spread_.get(), distortion_spread_.get() });
488 spread_visualizer_->setBounds(frame_spread_->getX(), widget_margin,
489 distortion_spread_->getRight() - frame_spread_->getX(), text_height);
498 oscillator_active_ = oscillator->
activator();
499 oscillator_active_->addListener(
this);
500 voices_slider_->addListener(
this);
502 spread_visualizer_->setVoicesSlider(voices_slider_);
514 if (voices_slider_ && oscillator_active_)
515 setActive(voices_slider_->getValue() > 1.0 && oscillator_active_->getToggleState());
523 if (changed_slider == voices_slider_)
534 if (clicked_button == oscillator_active_)
552 std::unique_ptr<SynthButton> spectral_unison_;
553 std::unique_ptr<TextSelector> stack_style_;
554 std::unique_ptr<SynthSlider> detune_range_;
555 std::unique_ptr<SynthSlider> stereo_spread_;
556 std::unique_ptr<SynthSlider> blend_;
558 std::unique_ptr<SpreadVisualizer> spread_visualizer_;
559 std::unique_ptr<SynthSlider> frame_spread_;
560 std::unique_ptr<SynthSlider> distortion_spread_;
561 std::unique_ptr<SynthSlider> spectral_morph_spread_;
563 ToggleButton* oscillator_active_;
573 oscillator_options_ = std::make_unique<OscillatorOptions>(index);
576 oscillator_unison_ = std::make_unique<OscillatorUnison>(index, mono_modulations, poly_modulations);
585 int options_width = getWidth() * 0.22f;
586 oscillator_options_->setBounds(0, 0, options_width, getHeight());
588 int unison_x = oscillator_options_->getRight() + padding;
589 oscillator_unison_->setBounds(unison_x, 0, getWidth() - unison_x, getHeight());
593 oscillator_options_->passOscillatorSection(oscillator);
594 oscillator_unison_->passOscillatorSection(oscillator);
A renderer for drawing a series of bars using OpenGL.
Definition bar_renderer.h:18
void setColor(const Colour &color)
Sets the color of the bars.
Definition bar_renderer.h:76
force_inline void setX(int index, float val)
Sets the x-position for all vertices of a specific bar.
Definition bar_renderer.h:141
force_inline void setBottom(int index, float val)
Sets the bottom y-position of a specific bar.
Definition bar_renderer.h:165
force_inline void setAdditiveBlending(bool additive_blending)
Enables or disables additive blending for the bar rendering.
Definition bar_renderer.h:251
void setBarWidth(float bar_width)
Sets the relative width of each bar.
Definition bar_renderer.h:94
virtual void render(OpenGlWrapper &open_gl, bool animate) override
Renders the bars using the current OpenGL context.
Definition bar_renderer.cpp:149
force_inline void setY(int index, float val)
Sets the top y-position of a specific bar.
Definition bar_renderer.h:154
float findValue(Skin::ValueId value_id)
Finds a float value from the skin associated with this component's parent.
Definition open_gl_component.cpp:173
void passOscillatorSection(const OscillatorSection *oscillator)
Passes a reference to the associated OscillatorSection to allow control synchronization.
Definition oscillator_advanced_section.cpp:592
void resized() override
Called when this component is resized. Resets the bounds of child components.
Definition oscillator_advanced_section.cpp:582
virtual ~OscillatorAdvancedSection()
Destructor.
Definition oscillator_advanced_section.cpp:580
OscillatorAdvancedSection(int index, const vital::output_map &mono_modulations, const vital::output_map &poly_modulations)
Constructs an OscillatorAdvancedSection for a given oscillator index.
Definition oscillator_advanced_section.cpp:569
A section providing toggleable oscillator options such as MIDI tracking and high-resolution wavetable...
Definition oscillator_advanced_section.cpp:16
void passOscillatorSection(const OscillatorSection *oscillator)
Associates this options section with an OscillatorSection for activation tracking.
Definition oscillator_advanced_section.cpp:110
void paintBackground(Graphics &g) override
Paints the background of the options section, including component backgrounds.
Definition oscillator_advanced_section.cpp:48
void resized() override
Called when resized. Updates component bounds.
Definition oscillator_advanced_section.cpp:69
virtual ~OscillatorOptions()
Destructor.
Definition oscillator_advanced_section.cpp:42
void buttonClicked(Button *clicked_button) override
Responds to button clicks within this section.
Definition oscillator_advanced_section.cpp:99
OscillatorOptions(int index)
Constructs an OscillatorOptions section for a specified oscillator index.
Definition oscillator_advanced_section.cpp:22
void setAllValues(vital::control_map &controls) override
Sets all UI control values from a given control map.
Definition oscillator_advanced_section.cpp:88
void paintBackgroundShadow(Graphics &g) override
Paints the background shadow if the oscillator is active.
Definition oscillator_advanced_section.cpp:61
A UI section representing an oscillator in the synthesizer.
Definition oscillator_section.h:32
const SynthSlider * getDistortionSlider() const
Gets the distortion slider.
Definition oscillator_section.h:334
Slider * getWaveFrameSlider()
Gets the wave frame slider.
Definition oscillator_section.cpp:1034
const SynthSlider * getSpectralMorphSlider() const
Gets the spectral morph slider.
Definition oscillator_section.h:328
SynthSlider * getVoicesSlider() const
Gets the unison voices slider.
Definition oscillator_section.h:316
A section providing control over unison parameters such as blend, detune range, stereo spread,...
Definition oscillator_advanced_section.cpp:367
void checkActive()
Checks if this section should be active based on voices and oscillator activation states.
Definition oscillator_advanced_section.cpp:513
void setAllValues(vital::control_map &controls) override
Sets control values and updates active state.
Definition oscillator_advanced_section.cpp:544
OscillatorUnison(int index, const vital::output_map &mono_modulations, const vital::output_map &poly_modulations)
Constructs an OscillatorUnison section for a specified oscillator.
Definition oscillator_advanced_section.cpp:375
void resized() override
Resizes the unison controls.
Definition oscillator_advanced_section.cpp:465
void sliderValueChanged(Slider *changed_slider) override
Handles slider value changes.
Definition oscillator_advanced_section.cpp:522
void passOscillatorSection(const OscillatorSection *oscillator)
Passes a reference to the associated OscillatorSection for voice and activity tracking.
Definition oscillator_advanced_section.cpp:496
void buttonClicked(Button *clicked_button) override
Handles button clicks, including activation toggle.
Definition oscillator_advanced_section.cpp:533
void paintBackgroundShadow(Graphics &g) override
Paints background shadows if active.
Definition oscillator_advanced_section.cpp:457
virtual ~OscillatorUnison()=default
Destructor.
void paintBackground(Graphics &g) override
Paints the background and labels for the unison section.
Definition oscillator_advanced_section.cpp:438
@ kWidgetMargin
Definition skin.h:103
@ kPadding
Definition skin.h:81
@ kLabelBackgroundRounding
Definition skin.h:74
@ kWidgetRoundedCorner
Definition skin.h:104
@ kWidgetBackground
Definition skin.h:173
@ kWidgetSecondary1
Definition skin.h:168
@ kTextComponentBackground
Definition skin.h:147
A visualization component for unison voice spread of various oscillator parameters.
Definition oscillator_advanced_section.cpp:130
void setDistortionSlider(const SynthSlider *slider)
Sets the slider controlling the distortion amount parameter.
Definition oscillator_advanced_section.cpp:221
void setDistortionSpreadSlider(const SynthSlider *slider)
Sets the slider controlling the distortion spread.
Definition oscillator_advanced_section.cpp:239
void setSpectralSpreadSlider(const SynthSlider *slider)
Sets the slider controlling the spectral morph spread.
Definition oscillator_advanced_section.cpp:233
static constexpr int kNumSpreads
Number of parameter spreads visualized.
Definition oscillator_advanced_section.cpp:132
SpreadVisualizer(int index, const vital::output_map &mono_modulations, const vital::output_map &poly_modulations)
Constructs a SpreadVisualizer for a given oscillator index and modulation maps.
Definition oscillator_advanced_section.cpp:140
void setFrameSlider(const SynthSlider *slider)
Sets the slider controlling the wave frame parameter.
Definition oscillator_advanced_section.cpp:209
void render(OpenGlWrapper &open_gl, bool animate) override
Renders the bars representing the spread of unison voices.
Definition oscillator_advanced_section.cpp:272
void setTableSpreadSlider(const SynthSlider *slider)
Sets the slider controlling the table spread (frame_spread).
Definition oscillator_advanced_section.cpp:227
void setVoicesSlider(const SynthSlider *slider)
Sets the slider controlling the number of unison voices.
Definition oscillator_advanced_section.cpp:203
void setSpectralMorphSlider(const SynthSlider *slider)
Sets the slider controlling the spectral morph parameter.
Definition oscillator_advanced_section.cpp:215
void paintBackground(Graphics &g) override
Paints the background of the visualizer.
Definition oscillator_advanced_section.cpp:259
vital::poly_float getOutputsTotal(std::pair< vital::Output *, vital::Output * > outputs, vital::poly_float default_value, bool animate)
Retrieves the sum of mono and poly outputs or a default value if not enabled.
Definition oscillator_advanced_section.cpp:248
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193
void drawTextComponentBackground(Graphics &g, Rectangle< int > bounds, bool extend_to_label)
Draws a background for a text component area.
Definition synth_section.cpp:319
virtual void buttonClicked(Button *clicked_button) override
Called when a button is clicked. Updates the synth parameter accordingly.
Definition synth_section.cpp:398
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
void createOffOverlay()
Definition synth_section.cpp:514
void addSubSection(SynthSection *section, bool show=true)
Adds a subsection (another SynthSection) as a child.
Definition synth_section.cpp:457
virtual void resized() override
Called when the component is resized. Arranges layout of child components.
Definition synth_section.cpp:35
ToggleButton * activator() const
Gets the activator toggle button if any.
Definition synth_section.h:735
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 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
virtual void setAllValues(vital::control_map &controls)
Sets values for all known parameters from a control map.
Definition synth_section.cpp:827
float getTitleWidth()
Definition synth_section.cpp:629
virtual void paintTabShadow(Graphics &g)
Paints a tab-like shadow effect around the component.
Definition synth_section.cpp:188
float getWidgetMargin()
Definition synth_section.cpp:676
A specialized slider with extended functionality for modulation, parameter control,...
Definition synth_slider.h:314
static TextLookAndFeel * instance()
Singleton instance access.
Definition text_look_and_feel.h:106
static constexpr int kMaxUnison
Maximum number of unison voices.
Definition synth_oscillator.h:199
const std::string kUnisonStackNames[]
Names for different unison voice stacking modes.
Definition synth_strings.h:97
force_inline poly_float clamp(poly_float value, mono_float min, mono_float max)
Clamps each lane of a vector to [min, max].
Definition poly_utils.h:306
Contains classes and functions used within the Vital synthesizer framework.
std::map< std::string, Output * > output_map
Maps parameter names to Output pointers, representing output signals from various modules.
Definition synth_types.h:229
std::map< std::string, Value * > control_map
Maps parameter names to Value pointers representing synth control parameters.
Definition synth_types.h:214
constexpr int kNumOscillatorWaveFrames
Number of wave frames in each oscillator’s wavetable.
Definition synth_constants.h:19
A helper struct containing references to OpenGL context, shaders, and display scale.
Definition shaders.h:174
Represents a vector of floating-point values using SIMD instructions.
Definition poly_values.h:600
Declares the SynthSlider and related classes, providing various slider styles and functionality in th...
Declares the TextSelector class and PaintPatternSelector class for selecting text-based options and d...