34 container_ = std::make_unique<EffectsContainer>(
"container");
36 addAndMakeVisible(viewport_);
37 viewport_.setViewedComponent(container_.get());
39 viewport_.setScrollBarsShown(
false,
false,
true,
false);
41 chorus_section_ = std::make_unique<ChorusSection>(
"CHORUS", mono_modulations);
42 container_->addSubSection(chorus_section_.get());
44 compressor_section_ = std::make_unique<CompressorSection>(
"COMPRESSOR");
45 container_->addSubSection(compressor_section_.get());
47 delay_section_ = std::make_unique<DelaySection>(
"DELAY", mono_modulations);
48 container_->addSubSection(delay_section_.get());
50 distortion_section_ = std::make_unique<DistortionSection>(
"DISTORTION", mono_modulations);
51 container_->addSubSection(distortion_section_.get());
53 equalizer_section_ = std::make_unique<EqualizerSection>(
"EQ", mono_modulations);
54 container_->addSubSection(equalizer_section_.get());
56 flanger_section_ = std::make_unique<FlangerSection>(
"FLANGER", mono_modulations);
57 container_->addSubSection(flanger_section_.get());
59 phaser_section_ = std::make_unique<PhaserSection>(
"PHASER", mono_modulations);
60 container_->addSubSection(phaser_section_.get());
62 reverb_section_ = std::make_unique<ReverbSection>(
"REVERB", mono_modulations);
63 container_->addSubSection(reverb_section_.get());
65 filter_section_ = std::make_unique<FilterSection>(
"fx", mono_modulations);
66 container_->addSubSection(filter_section_.get());
68 effect_order_ = std::make_unique<DragDropEffectOrder>(
"effect_chain_order");
70 effect_order_->addListener(
this);
74 effects_list_[0] = chorus_section_.get();
75 effects_list_[1] = compressor_section_.get();
76 effects_list_[2] = delay_section_.get();
77 effects_list_[3] = distortion_section_.get();
78 effects_list_[4] = equalizer_section_.get();
79 effects_list_[5] = filter_section_.get();
80 effects_list_[6] = flanger_section_.get();
81 effects_list_[7] = phaser_section_.get();
82 effects_list_[8] = reverb_section_.get();
84 scroll_bar_ = std::make_unique<OpenGlScrollBar>();
85 scroll_bar_->setShrinkLeft(
true);
86 addAndMakeVisible(scroll_bar_.get());
88 scroll_bar_->addListener(
this);
95 chorus_section_ =
nullptr;
96 compressor_section_ =
nullptr;
97 delay_section_ =
nullptr;
98 distortion_section_ =
nullptr;
99 equalizer_section_ =
nullptr;
100 flanger_section_ =
nullptr;
101 phaser_section_ =
nullptr;
102 reverb_section_ =
nullptr;
103 effect_order_ =
nullptr;
108 g.setColour(background);
118 int height = std::max(container_->getHeight(), getHeight());
120 Image background_image = Image(Image::ARGB, container_->getWidth() * mult, height * mult,
true);
122 Graphics background_graphics(background_image);
123 background_graphics.addTransform(AffineTransform::scale(mult));
124 background_graphics.fillAll(background);
125 container_->paintBackground(background_graphics);
130 static constexpr float kEffectOrderWidthPercent = 0.2f;
132 ScopedLock lock(open_gl_critical_section_);
134 int order_width = getWidth() * kEffectOrderWidthPercent;
135 effect_order_->setBounds(0, 0, order_width, getHeight());
139 int viewport_x = order_width + large_padding - shadow_width;
140 int viewport_width = getWidth() - viewport_x - large_padding + 2 * shadow_width;
141 viewport_.setBounds(viewport_x, 0, viewport_width, getHeight());
144 scroll_bar_->setBounds(getWidth() - large_padding + 1, 0, large_padding - 2, getHeight());
151 ScopedLock lock(open_gl_critical_section_);
158 ScopedLock lock(open_gl_critical_section_);
161 effects_list_[order_index]->
activator()->setToggleState(
true, sendNotification);
168 if (getWidth() <= 0 || getHeight() <= 0)
174 int start_x = effect_order_->getRight() + large_padding;
175 int effect_width = getWidth() - start_x - large_padding;
178 int effect_height = 2 * knob_section_height - widget_margin;
181 Point<int> position = viewport_.getViewPosition();
184 bool enabled = effect_order_->effectEnabled(i);
185 effects_list_[effect_order_->getEffectIndex(i)]->setVisible(enabled);
187 effects_list_[effect_order_->getEffectIndex(i)]->setBounds(shadow_width, y, effect_width, effect_height);
188 y += effect_height + padding;
192 container_->setBounds(0, 0, viewport_.getWidth(), y - padding);
193 viewport_.setViewPosition(position);
195 for (
Listener* listener : listeners_)
196 listener->effectsMoved();
198 container_->setScrollWheelEnabled(container_->getHeight() <= viewport_.getHeight());
204 background_.
init(open_gl);
209 ScopedLock lock(open_gl_critical_section_);
216 float width_ratio = image_width / (container_->getWidth() * mult);
217 float height_ratio = image_height / (viewport_.getHeight() * mult);
218 float y_offset = (2.0f * viewport_.getViewPositionY()) / getHeight();
220 background_.
setTopLeft(-1.0f, 1.0f + y_offset);
221 background_.
setTopRight(-1.0 + 2.0f * width_ratio, 1.0f + y_offset);
222 background_.
setBottomLeft(-1.0f, 1.0f - 2.0f * height_ratio + y_offset);
223 background_.
setBottomRight(-1.0 + 2.0f * width_ratio, 1.0f - 2.0f * height_ratio + y_offset);
225 background_.
setColor(Colours::white);
236 viewport_.setViewPosition(Point<int>(0, range_start));
240 scroll_bar_->setRangeLimits(0.0, container_->getHeight());
241 scroll_bar_->setCurrentRange(scroll_bar_->getCurrentRangeStart(), viewport_.getHeight(), dontSendNotification);
Declares the ChorusSection class, which provides a UI for configuring chorus effects.
A container managing multiple DraggableEffect components, allowing reordering via drag and drop.
Definition drag_drop_effect_order.h:120
A container holding all the effect sections, painting their background and shadows.
Definition effects_interface.cpp:19
void paintBackground(Graphics &g) override
Definition effects_interface.cpp:26
EffectsContainer(String name)
Constructor.
Definition effects_interface.cpp:22
Interface for objects that need to respond when effects are moved or scrolled.
Definition effects_interface.h:69
void renderOpenGlComponents(OpenGlWrapper &open_gl, bool animate) override
Definition effects_interface.cpp:208
void redoBackgroundImage()
Updates the background image when needed, e.g., after reordering.
Definition effects_interface.cpp:115
void setEffectPositions()
Positions the effect sections based on their order and enabled states.
Definition effects_interface.cpp:167
void paintBackground(Graphics &g) override
Definition effects_interface.cpp:106
void scrollBarMoved(ScrollBar *scroll_bar, double range_start) override
Definition effects_interface.cpp:235
void orderChanged(DragDropEffectOrder *order) override
Definition effects_interface.cpp:150
void setScrollBarRange()
Updates the scrollbar range after changes.
Definition effects_interface.cpp:239
EffectsInterface(const vital::output_map &mono_modulations)
Definition effects_interface.cpp:33
void resized() override
Resizes and lays out the effects sections and the viewport.
Definition effects_interface.cpp:129
virtual ~EffectsInterface()
Destructor.
Definition effects_interface.cpp:94
void effectEnabledChanged(int order_index, bool enabled) override
Definition effects_interface.cpp:157
void initOpenGlComponents(OpenGlWrapper &open_gl) override
Definition effects_interface.cpp:203
void destroyOpenGlComponents(OpenGlWrapper &open_gl) override
Definition effects_interface.cpp:230
void addListener(Listener *listener)
Definition effects_interface.h:43
static bool setViewPort(Component *component, Rectangle< int > bounds, OpenGlWrapper &open_gl)
Sets the OpenGL viewport to match a specified rectangle within a component.
Definition open_gl_component.cpp:42
void setOwnImage(Image &image)
Sets the image from an owned copy.
Definition open_gl_image.h:69
void init(OpenGlWrapper &open_gl)
Initializes the OpenGL buffers and shader attributes needed for rendering the image.
Definition open_gl_image.cpp:33
void setBottomLeft(float x, float y)
Sets the bottom-left corner position of the image quad.
Definition open_gl_image.h:116
int getImageWidth()
Gets the width of the currently set image.
Definition open_gl_image.h:132
void drawImage(OpenGlWrapper &open_gl)
Draws the image to the current OpenGL context.
Definition open_gl_image.cpp:59
int getImageHeight()
Gets the height of the currently set image.
Definition open_gl_image.h:138
void setBottomRight(float x, float y)
Sets the bottom-right corner position of the image quad.
Definition open_gl_image.h:121
void setTopLeft(float x, float y)
Sets the top-left corner position of the image quad.
Definition open_gl_image.h:111
void destroy(OpenGlWrapper &open_gl)
Releases any OpenGL resources allocated by this object.
Definition open_gl_image.cpp:128
void setTopRight(float x, float y)
Sets the top-right corner position of the image quad.
Definition open_gl_image.h:126
void setColor(Colour color)
Sets the color tint applied to the image.
Definition open_gl_image.h:92
@ kWidgetMargin
Definition skin.h:103
@ kLargePadding
Definition skin.h:82
@ kBackground
Definition skin.h:128
@ kLightenScreen
Definition skin.h:141
@ kAllEffects
Definition skin.h:45
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193
virtual void renderOpenGlComponents(OpenGlWrapper &open_gl, bool animate)
Renders all OpenGL components in this section and sub-sections.
Definition synth_section.cpp:357
float getPadding()
Definition synth_section.cpp:660
virtual void animate(bool animate)
Triggers animation state change in sub-sections if needed.
Definition synth_section.cpp:822
void addSubSection(SynthSection *section, bool show=true)
Adds a subsection (another SynthSection) as a child.
Definition synth_section.cpp:457
int getComponentShadowWidth()
Gets the width of shadow around components.
Definition synth_section.cpp:184
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
void paintChildBackground(Graphics &g, SynthSection *child)
Paints a child's background specifically.
Definition synth_section.cpp:292
void paintChildrenBackgrounds(Graphics &g)
Paints the backgrounds for all child sections.
Definition synth_section.cpp:274
virtual void paintChildrenShadows(Graphics &g)
Paints shadows for child sections.
Definition synth_section.cpp:260
virtual int getPixelMultiple() const
Definition synth_section.cpp:729
virtual void destroyOpenGlComponents(OpenGlWrapper &open_gl)
Destroys all OpenGL components in this section and sub-sections.
Definition synth_section.cpp:383
float size_ratio_
Definition synth_section.h:821
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
float getKnobSectionHeight()
Definition synth_section.cpp:633
void addOpenGlComponent(OpenGlComponent *open_gl_component, bool to_beginning=false)
Definition synth_section.cpp:489
void setSkinOverride(Skin::SectionOverride skin_override)
Definition synth_section.h:303
virtual void initOpenGlComponents(OpenGlWrapper &open_gl)
Initializes all OpenGL components in this section and sub-sections.
Definition synth_section.cpp:349
virtual void repaintBackground()
Requests a repaint of the background.
Definition synth_section.cpp:96
Declares the CompressorSection class, providing a UI for a multiband compressor.
Declares the DelaySection class and related viewer classes for displaying and controlling a delay eff...
Declares the DistortionSection class and related components for displaying and controlling a distorti...
Declares the EffectsInterface class and related components for managing and displaying multiple effec...
Declares the EqualizerSection class, providing a UI for a 3-band equalizer with adjustable modes and ...
@ kNumEffects
Definition synth_constants.h:187
force_inline int nextPowerOfTwo(mono_float value)
Finds the next power of two greater than or equal to a float value.
Definition utils.h:370
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