Vital
Loading...
Searching...
No Matches
synth_plugin.h
Go to the documentation of this file.
1/*
2Summary:
3
4SynthPlugin is the core plugin class handling parameter management, saving/loading state, preparing audio processing, and communicating with the host. It integrates the synth engine, GUI interface, and handles parameter automation through ValueBridge instances. It also ensures that parameter changes and preset loading are communicated effectively to the GUI and host.
5 */
6
7#pragma once
8
9#include "JuceHeader.h"
10
11#include "synth_base.h"
12#include "value_bridge.h"
13
14class ValueBridge;
15
26class SynthPlugin : public SynthBase, public AudioProcessor, public ValueBridge::Listener {
27 public:
28 static constexpr int kSetProgramWaitMilliseconds = 500;
29
36
40 virtual ~SynthPlugin();
41
47
52 void beginChangeGesture(const std::string& name) override;
53
58 void endChangeGesture(const std::string& name) override;
59
65 void setValueNotifyHost(const std::string& name, vital::mono_float value) override;
66
71 const CriticalSection& getCriticalSection() override;
72
77 void pauseProcessing(bool pause) override;
78
84 void prepareToPlay(double sample_rate, int buffer_size) override;
85
89 void releaseResources() override;
90
96 void processBlock(AudioSampleBuffer&, MidiBuffer&) override;
97
102 AudioProcessorEditor* createEditor() override;
103
108 bool hasEditor() const override;
109
114 const String getName() const override;
115
120 bool supportsMPE() const override { return true; }
121
126 const String getInputChannelName(int channel_index) const override;
127
132 const String getOutputChannelName(int channel_index) const override;
133
139 bool isInputChannelStereoPair(int index) const override;
140
146 bool isOutputChannelStereoPair(int index) const override;
147
152 bool acceptsMidi() const override;
153
158 bool producesMidi() const override;
159
164 bool silenceInProducesSilenceOut() const override;
165
170 double getTailLengthSeconds() const override;
171
175 int getNumPrograms() override { return 1; }
176
180 int getCurrentProgram() override { return 0; }
181
186 void setCurrentProgram(int index) override { }
187
193 const String getProgramName(int index) override;
194
200 void changeProgramName(int index, const String& new_name) override { }
201
206 void getStateInformation(MemoryBlock& destData) override;
207
213 void setStateInformation(const void* data, int size_in_bytes) override;
214
219 AudioProcessorParameter* getBypassParameter() const override { return bypass_parameter_; }
220
226 void parameterChanged(std::string name, vital::mono_float value) override;
227
228 private:
229 ValueBridge* bypass_parameter_;
230 double last_seconds_time_;
231 AudioPlayHead::CurrentPositionInfo position_info_;
232
233 std::map<std::string, ValueBridge*> bridge_lookup_;
234
235 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SynthPlugin)
236};
237
A base class providing foundational functionality for the Vital synthesizer’s engine,...
Definition synth_base.h:42
An interface class linking the Vital synthesizer backend (SynthBase) with a GUI.
Definition synth_gui_interface.h:56
An AudioProcessor implementation for a synthesizer plugin.
Definition synth_plugin.h:26
void parameterChanged(std::string name, vital::mono_float value) override
Called when a parameter changes externally via a ValueBridge.
Definition synth_plugin.cpp:188
void changeProgramName(int index, const String &new_name) override
Changes the name of a program (not implemented).
Definition synth_plugin.h:200
void processBlock(AudioSampleBuffer &, MidiBuffer &) override
Process audio and MIDI data each block.
Definition synth_plugin.cpp:139
void endChangeGesture(const std::string &name) override
Ends a parameter change gesture for the specified parameter.
Definition synth_plugin.cpp:51
void setStateInformation(const void *data, int size_in_bytes) override
Restores the plugin state from a memory block.
Definition synth_plugin.cpp:204
void prepareToPlay(double sample_rate, int buffer_size) override
Prepare the plugin to play with the given sample rate and buffer size.
Definition synth_plugin.cpp:128
bool acceptsMidi() const override
Checks if the plugin accepts MIDI input.
Definition synth_plugin.cpp:95
void releaseResources() override
Release any resources allocated for playback.
Definition synth_plugin.cpp:135
bool silenceInProducesSilenceOut() const override
Checks if silence in leads to silence out.
Definition synth_plugin.cpp:111
const String getOutputChannelName(int channel_index) const override
Returns the output channel name.
Definition synth_plugin.cpp:83
AudioProcessorEditor * createEditor() override
Creates and returns the AudioProcessorEditor for this plugin.
Definition synth_plugin.cpp:183
bool producesMidi() const override
Checks if the plugin produces MIDI output.
Definition synth_plugin.cpp:103
void beginChangeGesture(const std::string &name) override
Begins a parameter change gesture for the specified parameter.
Definition synth_plugin.cpp:45
void getStateInformation(MemoryBlock &destData) override
Saves the plugin state to a memory block.
Definition synth_plugin.cpp:193
int getNumPrograms() override
Returns the number of programs (only one here).
Definition synth_plugin.h:175
void setValueNotifyHost(const std::string &name, vital::mono_float value) override
Sets a parameter value and notifies the host.
Definition synth_plugin.cpp:57
bool supportsMPE() const override
Returns whether the plugin supports MPE (MIDI Polyphonic Expression).
Definition synth_plugin.h:120
AudioProcessorParameter * getBypassParameter() const override
Returns the bypass parameter for hosts that support bypass.
Definition synth_plugin.h:219
static constexpr int kSetProgramWaitMilliseconds
Wait time after setting a program.
Definition synth_plugin.h:28
const String getInputChannelName(int channel_index) const override
Returns the input channel name.
Definition synth_plugin.cpp:79
const String getProgramName(int index) override
Gets the name of a program.
Definition synth_plugin.cpp:119
void setCurrentProgram(int index) override
Sets the current program (does nothing here).
Definition synth_plugin.h:186
bool isInputChannelStereoPair(int index) const override
Checks if the given input channel forms a stereo pair.
Definition synth_plugin.cpp:87
bool hasEditor() const override
Checks if the plugin has an editor.
Definition synth_plugin.cpp:179
int getCurrentProgram() override
Returns the current program index (always 0 here).
Definition synth_plugin.h:180
SynthGuiInterface * getGuiInterface() override
Returns the GUI interface for this plugin.
Definition synth_plugin.cpp:37
const CriticalSection & getCriticalSection() override
Returns the CriticalSection for thread synchronization.
Definition synth_plugin.cpp:65
virtual ~SynthPlugin()
Destructor, cleans up allocated resources.
Definition synth_plugin.cpp:32
bool isOutputChannelStereoPair(int index) const override
Checks if the given output channel forms a stereo pair.
Definition synth_plugin.cpp:91
void pauseProcessing(bool pause) override
Pauses or resumes audio processing.
Definition synth_plugin.cpp:70
const String getName() const override
Returns the name of the plugin.
Definition synth_plugin.cpp:75
SynthPlugin()
Constructs the SynthPlugin.
Definition synth_plugin.cpp:12
double getTailLengthSeconds() const override
Gets the plugin's tail length in seconds.
Definition synth_plugin.cpp:115
An interface for receiving parameter change notifications from the ValueBridge.
Definition value_bridge.h:27
A parameter bridge that connects a vital::Value to an AudioProcessorParameter, allowing the host to m...
Definition value_bridge.h:17
float mono_float
Definition common.h:33