Vital
Loading...
Searching...
No Matches
lfo_section.h
Go to the documentation of this file.
1#pragma once
2
3#include "JuceHeader.h"
4
5#include "synth_section.h"
6#include "lfo_editor.h"
7#include "preset_selector.h"
8
9class RetriggerSelector;
10class SynthSlider;
11class TempoSelector;
12class TextSelector;
13class LineGenerator;
15
31class LfoSection : public SynthSection,
34public:
47
54 static std::vector<std::pair<float, float>> getPaintPattern(int pattern) {
55 if (pattern == LfoSection::kHalf) {
56 return {
57 { 0.0f, 1.0f },
58 { 0.5f, 1.0f },
59 { 0.5f, 0.0f },
60 { 1.0f, 0.0f }
61 };
62 }
63 if (pattern == LfoSection::kDown) {
64 return {
65 { 0.0f, 1.0f },
66 { 1.0f, 0.0f }
67 };
68 }
69 if (pattern == LfoSection::kUp) {
70 return {
71 { 0.0f, 0.0f },
72 { 1.0f, 1.0f }
73 };
74 }
75 if (pattern == LfoSection::kTri) {
76 return {
77 { 0.0f, 0.0f },
78 { 0.5f, 1.0f },
79 { 1.0f, 0.0f }
80 };
81 }
82 return {
83 { 0.0f, 1.0f },
84 { 1.0f, 1.0f }
85 };
86 }
87
97 LfoSection(String name, std::string value_prepend,
98 LineGenerator* lfo_source,
99 const vital::output_map& mono_modulations,
100 const vital::output_map& poly_modulations);
101
106
114 void paintBackground(Graphics& g) override;
115
121 void resized() override;
122
126 void reset() override;
127
133 void setAllValues(vital::control_map& controls) override;
134
140 void sliderValueChanged(Slider* changed_slider) override;
141
147 void buttonClicked(Button* clicked_button) override;
148
154 void setPhase(float phase) override { phase_->setValue(phase); }
155
162 void lineEditorScrolled(const MouseEvent& e, const MouseWheelDetails& wheel) override;
163
170 void togglePaintMode(bool enabled, bool temporary_switch) override;
171
175 void importLfo() override;
176
180 void exportLfo() override;
181
185 void fileLoaded() override;
186
192 void loadFile(const File& file) override;
193
199 File getCurrentFile() override { return current_file_; }
200
204 void prevClicked() override;
205
209 void nextClicked() override;
210
216 void textMouseDown(const MouseEvent& e) override;
217
223 void setSmoothModeSelected(int result);
224
225private:
229 File current_file_;
230
234 std::unique_ptr<LfoEditor> editor_;
235
239 std::unique_ptr<PresetSelector> preset_selector_;
240
244 std::unique_ptr<SynthSlider> phase_;
245
249 std::unique_ptr<SynthSlider> frequency_;
250
254 std::unique_ptr<SynthSlider> tempo_;
255
259 std::unique_ptr<SynthSlider> keytrack_transpose_;
260
264 std::unique_ptr<SynthSlider> keytrack_tune_;
265
269 std::unique_ptr<SynthSlider> fade_;
270
274 std::unique_ptr<SynthSlider> smooth_;
275
279 std::string smooth_mode_control_name_;
280
284 std::unique_ptr<PlainTextComponent> smooth_mode_text_;
285
289 std::unique_ptr<ShapeButton> smooth_mode_type_selector_;
290
294 std::unique_ptr<SynthSlider> delay_;
295
299 std::unique_ptr<SynthSlider> stereo_;
300
304 std::unique_ptr<TempoSelector> sync_;
305
309 std::unique_ptr<TextSelector> sync_type_;
310
314 std::unique_ptr<PaintPatternSelector> paint_pattern_;
315
319 std::unique_ptr<OpenGlQuad> transpose_tune_divider_;
320
324 std::unique_ptr<SynthSlider> grid_size_x_;
325
329 std::unique_ptr<SynthSlider> grid_size_y_;
330
334 std::unique_ptr<OpenGlShapeButton> paint_;
335
339 std::unique_ptr<OpenGlShapeButton> lfo_smooth_;
340
344 int current_preset_;
345
346 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LfoSection)
347};
A user interface section that displays and controls an LFO (Low Frequency Oscillator) in the synthesi...
Definition lfo_section.h:33
static std::vector< std::pair< float, float > > getPaintPattern(int pattern)
Retrieves a paint pattern as a vector of (x, y) pairs.
Definition lfo_section.h:54
void textMouseDown(const MouseEvent &e) override
Handles mouse-down events on the text component, usually to open a file browser.
Definition lfo_section.cpp:479
void prevClicked() override
Loads the previous LFO preset.
Definition lfo_section.cpp:451
void nextClicked() override
Loads the next LFO preset.
Definition lfo_section.cpp:463
void loadFile(const File &file) override
Loads the LFO configuration from the specified file.
Definition lfo_section.cpp:516
File getCurrentFile() override
Retrieves the current LFO file.
Definition lfo_section.h:199
void lineEditorScrolled(const MouseEvent &e, const MouseWheelDetails &wheel) override
Responds to scrolling events in the line editor component.
Definition lfo_section.cpp:390
~LfoSection()
Destructor.
void reset() override
Resets all LFO settings to their default states.
Definition lfo_section.cpp:311
void importLfo() override
Imports an LFO from a user-selected file.
Definition lfo_section.cpp:411
void resized() override
Called when the component is resized.
Definition lfo_section.cpp:245
void setAllValues(vital::control_map &controls) override
Updates all control values in this section from the given map of controls.
Definition lfo_section.cpp:322
void exportLfo() override
Exports the current LFO configuration to a user-selected file.
Definition lfo_section.cpp:423
LfoSection(String name, std::string value_prepend, LineGenerator *lfo_source, const vital::output_map &mono_modulations, const vital::output_map &poly_modulations)
Constructs a new LfoSection.
Definition lfo_section.cpp:21
PaintPattern
Enumerates the paint patterns used for LFO shape painting.
Definition lfo_section.h:39
@ kDown
A downward linear ramp.
Definition lfo_section.h:42
@ kUp
An upward linear ramp.
Definition lfo_section.h:43
@ kTri
A triangular shape.
Definition lfo_section.h:44
@ kStep
A step pattern (horizontal line at the top).
Definition lfo_section.h:40
@ kNumPaintPatterns
The number of available paint patterns.
Definition lfo_section.h:45
@ kHalf
A pattern rising half-way and then dropping to zero.
Definition lfo_section.h:41
void setPhase(float phase) override
Sets the LFO phase.
Definition lfo_section.h:154
void buttonClicked(Button *clicked_button) override
Responds to a button click event.
Definition lfo_section.cpp:362
void setSmoothModeSelected(int result)
Sets the selected smooth mode.
Definition lfo_section.cpp:499
void fileLoaded() override
Called when an LFO file has been successfully loaded.
Definition lfo_section.cpp:444
void togglePaintMode(bool enabled, bool temporary_switch) override
Toggles paint mode for the LFO editor.
Definition lfo_section.cpp:403
void sliderValueChanged(Slider *changed_slider) override
Responds to a slider value change event.
Definition lfo_section.cpp:341
void paintBackground(Graphics &g) override
Paints the background of the LFO section.
Definition lfo_section.cpp:199
Interface for classes that want to receive notifications about line editor changes.
Definition line_editor.h:86
A class for generating and storing a line shape, defined by a series of points and associated powers.
Definition line_generator.h:20
A specialized TextSelector that draws a visual pattern instead of text.
Definition text_selector.h:47
Interface for objects that want to be notified of PresetSelector events.
Definition preset_selector.h:24
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193
A specialized slider with extended functionality for modulation, parameter control,...
Definition synth_slider.h:314
A slider component that allows selection between different tempo modes (seconds, tempo,...
Definition tempo_selector.h:14
A specialized SynthSlider that displays a popup menu of text options.
Definition text_selector.h:14
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
Declares the PresetSelector class which provides a UI component for selecting presets.