Vital
Loading...
Searching...
No Matches
sample_section.h
Go to the documentation of this file.
1#pragma once
2
3#include "JuceHeader.h"
4#include "synth_section.h"
5#include "preset_selector.h"
6#include "sample_viewer.h"
8
9class SynthSlider;
11
25public:
30 class Listener {
31 public:
32 virtual ~Listener() {}
38 virtual void sampleDestinationChanged(SampleSection* sample, int destination) = 0;
39 };
40
45 SampleSection(String name);
46
49
54 void parentHierarchyChanged() override;
55
60 void paintBackground(Graphics& g) override;
61
66 void paintBackgroundShadow(Graphics& g) override { if (isActive()) paintTabShadow(g); }
67
72 void setActive(bool active) override;
73
77 void resized() override;
78
82 void reset() override;
83
88 void setAllValues(vital::control_map& controls) override;
89
94 void buttonClicked(Button* clicked_button) override;
95
100 void setDestinationSelected(int selection);
101
105 void setupDestination();
106
112 void toggleFilterInput(int filter_index, bool on);
113
118 void loadFile(const File& file) override;
119
124 void sampleLoaded(const File& file) override { loadFile(file); }
125
130 File getCurrentFile() override { return File(sample_->getLastBrowsedFile()); }
131
135 void prevClicked() override;
136
140 void nextClicked() override;
141
146 void textMouseDown(const MouseEvent& e) override;
147
151 void quantizeUpdated() override;
152
157 void addListener(Listener* listener) { listeners_.push_back(listener); }
158
159private:
160 std::vector<Listener*> listeners_;
161
162 std::unique_ptr<TransposeQuantizeButton> transpose_quantize_button_;
163 std::unique_ptr<SynthSlider> transpose_;
164 std::unique_ptr<SynthSlider> tune_;
165 std::unique_ptr<SynthSlider> pan_;
166 std::unique_ptr<SynthSlider> level_;
167 std::unique_ptr<SampleViewer> sample_viewer_;
168 std::unique_ptr<PresetSelector> preset_selector_;
169
170 int current_destination_;
171 std::string destination_control_name_;
172 std::unique_ptr<PlainTextComponent> destination_text_;
173 std::unique_ptr<ShapeButton> destination_selector_;
174 std::unique_ptr<OpenGlShapeButton> prev_destination_;
175 std::unique_ptr<OpenGlShapeButton> next_destination_;
176
177 std::unique_ptr<SynthButton> on_;
178 std::unique_ptr<OpenGlShapeButton> loop_;
179 std::unique_ptr<OpenGlShapeButton> bounce_;
180 std::unique_ptr<OpenGlShapeButton> keytrack_;
181 std::unique_ptr<OpenGlShapeButton> random_phase_;
182
183 AudioSampleBuffer sample_buffer_;
184 vital::Sample* sample_;
185
186 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SampleSection)
187};
A ToggleButton that uses an OpenGlShapeButtonComponent for its rendering.
Definition synth_button.h:110
Interface for objects that want to be notified of PresetSelector events.
Definition preset_selector.h:24
Interface for receiving events when the sample destination changes.
Definition sample_section.h:30
virtual void sampleDestinationChanged(SampleSection *sample, int destination)=0
Called when the sample output routing destination changes.
virtual ~Listener()
Definition sample_section.h:32
A UI section for managing and editing a sample source.
Definition sample_section.h:24
void nextClicked() override
Called when the "next" button is clicked to cycle through samples.
Definition sample_section.cpp:331
void setupDestination()
Configures the destination text and notifies listeners of the new destination.
Definition sample_section.cpp:307
void buttonClicked(Button *clicked_button) override
Handles button click events for this section.
Definition sample_section.cpp:276
void sampleLoaded(const File &file) override
Callback for when a sample is loaded externally through the SampleViewer.
Definition sample_section.h:124
void quantizeUpdated() override
Called when quantization is updated from the TransposeQuantizeButton.
Definition sample_section.cpp:351
void parentHierarchyChanged() override
Called when the parent hierarchy changes. Used to acquire a pointer to the synth and associated sampl...
Definition sample_section.cpp:119
void paintBackground(Graphics &g) override
Paints the background of the sample section, including labels and visual layouts.
Definition sample_section.cpp:130
void loadFile(const File &file) override
Loads a sample file and updates the sample viewer and presets.
Definition sample_section.cpp:243
void paintBackgroundShadow(Graphics &g) override
Paints the background shadow if the section is active.
Definition sample_section.h:66
void prevClicked() override
Called when the "previous" button is clicked to cycle through samples.
Definition sample_section.cpp:322
~SampleSection()
Destructor.
void reset() override
Resets the sample section, updating display and reloading the sample if needed.
Definition sample_section.cpp:237
void setActive(bool active) override
Activates or deactivates the section.
Definition sample_section.cpp:174
void textMouseDown(const MouseEvent &e) override
Called when the user clicks on the text area (e.g., preset name) to browse samples.
Definition sample_section.cpp:340
void toggleFilterInput(int filter_index, bool on)
Toggles the filter input routing on or off for a particular filter index.
Definition sample_section.cpp:314
File getCurrentFile() override
Gets the currently loaded sample file.
Definition sample_section.h:130
void resized() override
Called when the component is resized to lay out children and controls.
Definition sample_section.cpp:179
void setAllValues(vital::control_map &controls) override
Sets all control values from a given control map.
Definition sample_section.cpp:267
SampleSection(String name)
Constructs a SampleSection with a given name.
Definition sample_section.cpp:14
void addListener(Listener *listener)
Adds a listener for destination change events.
Definition sample_section.h:157
void setDestinationSelected(int selection)
Sets the sample output routing destination and updates the UI.
Definition sample_section.cpp:298
Interface for objects that want to be notified when a sample is loaded.
Definition sample_viewer.h:32
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193
bool isActive() const
Checks if the section is currently active.
Definition synth_section.h:683
virtual void paintTabShadow(Graphics &g)
Paints a tab-like shadow effect around the component.
Definition synth_section.cpp:188
A specialized slider with extended functionality for modulation, parameter control,...
Definition synth_slider.h:314
Interface for objects that want to be notified of quantization changes.
Definition transpose_quantize.h:97
Holds and manages a single sampled waveform, including stereo or mono data and multiple band-limited ...
Definition sample_source.h:25
std::string getLastBrowsedFile() const
Returns the last browsed file path.
Definition sample_source.h:96
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.
Declares the SampleViewer class that displays and animates a waveform sample.
Declares classes for selecting and applying transpose quantization to notes.