Vital
Loading...
Searching...
No Matches
SynthBase Class Referenceabstract

A base class providing foundational functionality for the Vital synthesizer’s engine, UI integration, modulation system, MIDI mapping, and preset management. More...

#include <synth_base.h>

Inheritance diagram for SynthBase:
MidiManager::Listener HeadlessSynth SynthEditor SynthPlugin

Classes

struct  ValueChangedCallback
 A callback message used when values change, allowing asynchronous updates to GUI or host. More...
 

Public Member Functions

 SynthBase ()
 Constructs a SynthBase, initializing the sound engine, MIDI manager, wavetables, and settings.
 
virtual ~SynthBase ()
 Destroys the SynthBase, cleaning up resources such as sound engine and memory buffers.
 
void valueChanged (const std::string &name, vital::mono_float value)
 Updates the value of a control parameter.
 
void valueChangedThroughMidi (const std::string &name, vital::mono_float value) override
 Handles parameter changes triggered through MIDI mappings.
 
void pitchWheelMidiChanged (vital::mono_float value) override
 Called when the pitch wheel value changes via MIDI.
 
void modWheelMidiChanged (vital::mono_float value) override
 Called when the mod wheel value changes via MIDI.
 
void pitchWheelGuiChanged (vital::mono_float value)
 Called when the pitch wheel changes via the GUI or another external source.
 
void modWheelGuiChanged (vital::mono_float value)
 Called when the mod wheel changes via the GUI or another external source.
 
void presetChangedThroughMidi (File preset) override
 Called when a preset is changed through MIDI (e.g., program change messages).
 
void valueChangedExternal (const std::string &name, vital::mono_float value)
 Handles external (non-GUI, non-MIDI) value changes to parameters.
 
void valueChangedInternal (const std::string &name, vital::mono_float value)
 Handles internal value changes, updating the parameter and optionally notifying the host.
 
bool connectModulation (const std::string &source, const std::string &destination)
 Connects a modulation source to a destination parameter.
 
void connectModulation (vital::ModulationConnection *connection)
 Connects a modulation using a pre-existing ModulationConnection object.
 
void disconnectModulation (const std::string &source, const std::string &destination)
 Disconnects a modulation source from a destination parameter.
 
void disconnectModulation (vital::ModulationConnection *connection)
 Disconnects a modulation given a ModulationConnection object.
 
void clearModulations ()
 Clears all modulation connections.
 
void forceShowModulation (const std::string &source, bool force)
 Forces a modulation source to remain active even if not currently connected.
 
bool isModSourceEnabled (const std::string &source)
 Checks if a modulation source is currently enabled.
 
int getNumModulations (const std::string &destination)
 Counts how many modulations target a given parameter.
 
int getConnectionIndex (const std::string &source, const std::string &destination)
 Gets the index of a modulation connection given its source and destination.
 
vital::CircularQueue< vital::ModulationConnection * > getModulationConnections ()
 Gets all current modulation connections as a CircularQueue.
 
std::vector< vital::ModulationConnection * > getSourceConnections (const std::string &source)
 Returns all modulation connections from a particular source.
 
bool isSourceConnected (const std::string &source)
 Checks if a given modulation source has any active connections.
 
std::vector< vital::ModulationConnection * > getDestinationConnections (const std::string &destination)
 Returns all modulation connections targeting a given destination parameter.
 
const vital::StatusOutputgetStatusOutput (const std::string &name)
 Retrieves a status output by name.
 
vital::WavetablegetWavetable (int index)
 Gets a wavetable object from the engine.
 
WavetableCreatorgetWavetableCreator (int index)
 Gets a WavetableCreator for a given oscillator index.
 
vital::SamplegetSample ()
 Gets the Sample object used by the engine.
 
LineGeneratorgetLfoSource (int index)
 Retrieves an LFO source by index.
 
int getSampleRate ()
 Retrieves the current audio sample rate used by the engine.
 
void initEngine ()
 Initializes the engine to a default state, clearing modulations and resetting parameters.
 
void loadTuningFile (const File &file)
 Loads a tuning file into the synthesizer’s tuning system.
 
void loadInitPreset ()
 Loads an "init" preset, resetting Vital to its default initial state.
 
bool loadFromFile (File preset, std::string &error)
 Attempts to load a preset from a file.
 
void renderAudioToFile (File file, float seconds, float bpm, std::vector< int > notes, bool render_images)
 Renders audio to a WAV file for a given duration and note sequence.
 
void renderAudioForResynthesis (float *data, int samples, int note)
 Renders audio for the purpose of resynthesis into a provided buffer.
 
bool saveToFile (File preset)
 Saves the current preset state to the specified file.
 
bool saveToActiveFile ()
 Saves the current preset state to the active file (if any).
 
void clearActiveFile ()
 Clears the currently active preset file, meaning changes are not saved to a previously loaded file.
 
File getActiveFile ()
 Gets the currently active preset file.
 
void setMpeEnabled (bool enabled)
 Enables or disables MPE (MIDI Polyphonic Expression) mode.
 
virtual void beginChangeGesture (const std::string &name)
 Called when a parameter change gesture begins. Typically not implemented in this base class.
 
virtual void endChangeGesture (const std::string &name)
 Called when a parameter change gesture ends. Typically not implemented in this base class.
 
virtual void setValueNotifyHost (const std::string &name, vital::mono_float value)
 Called when a parameter changes to notify a potential host environment. Typically not implemented here.
 
void armMidiLearn (const std::string &name)
 Arms the given parameter name for MIDI learn, associating the next received MIDI control with it.
 
void cancelMidiLearn ()
 Cancels a previously armed MIDI learn operation.
 
void clearMidiLearn (const std::string &name)
 Clears the MIDI mapping for a given parameter name.
 
bool isMidiMapped (const std::string &name)
 Checks if a given parameter name is MIDI mapped.
 
void setAuthor (const String &author)
 Sets the author metadata of the current preset.
 
void setComments (const String &comments)
 Sets the comments or description metadata of the current preset.
 
void setStyle (const String &style)
 Sets the style metadata of the current preset (e.g., bass, lead, etc.).
 
void setPresetName (const String &preset_name)
 Sets the preset name.
 
void setMacroName (int index, const String &macro_name)
 Sets the name of a macro control by index.
 
String getAuthor ()
 Gets the author of the current preset.
 
String getComments ()
 Gets the comments for the current preset.
 
String getStyle ()
 Gets the style of the current preset.
 
String getPresetName ()
 Gets the current preset’s name.
 
String getMacroName (int index)
 Gets the name of a macro control by index.
 
vital::control_mapgetControls ()
 Provides access to the controls map (parameter name to Parameter pointer).
 
vital::SoundEnginegetEngine ()
 Returns a pointer to the SoundEngine used for audio and modulation processing.
 
MidiKeyboardState * getKeyboardState ()
 Retrieves the keyboard state (for processing MIDI note events from a virtual keyboard).
 
const vital::poly_floatgetOscilloscopeMemory ()
 Retrieves the oscilloscope memory for visualization of audio output waveforms.
 
const vital::StereoMemorygetAudioMemory ()
 Retrieves stereo memory holding recent audio output samples for visualization.
 
const vital::StereoMemorygetEqualizerMemory ()
 Retrieves memory used for equalizer visualization, if available.
 
vital::ModulationConnectionBankgetModulationBank ()
 Retrieves the ModulationConnectionBank managing all modulation connections.
 
void notifyOversamplingChanged ()
 Notifies that oversampling settings have changed, reinitializing the engine if needed.
 
void checkOversampling ()
 Checks and updates oversampling settings. May be called if parameters affecting oversampling change.
 
virtual const CriticalSection & getCriticalSection ()=0
 Provides access to the synth’s internal CriticalSection for thread safety.
 
virtual void pauseProcessing (bool pause)=0
 Pauses or resumes audio processing.
 
TuninggetTuning ()
 Returns a pointer to the synth's Tuning object.
 
- Public Member Functions inherited from MidiManager::Listener
virtual ~Listener ()
 

Static Public Attributes

static constexpr float kOutputWindowMinNote = 16.0f
 Minimum and maximum note values considered for output window display or related processing.
 
static constexpr float kOutputWindowMaxNote = 128.0f
 

Protected Member Functions

vital::modulation_change createModulationChange (vital::ModulationConnection *connection)
 Creates a modulation_change structure for a given connection, preparing it for engine operations.
 
bool isInvalidConnection (const vital::modulation_change &change)
 Checks if a modulation_change is invalid (e.g., creates a loop).
 
virtual SynthGuiInterfacegetGuiInterface ()=0
 Retrieves the GUI interface if available, for updating controls or notifications.
 
json saveToJson ()
 Serializes the current synth state into a JSON object.
 
bool loadFromJson (const json &state)
 Deserializes and applies the synth state from a JSON object.
 
vital::ModulationConnectiongetConnection (const std::string &source, const std::string &destination)
 Finds a ModulationConnection by source and destination names.
 
bool getNextModulationChange (vital::modulation_change &change)
 Attempts to dequeue a modulation_change for processing.
 
void clearModulationQueue ()
 Clears the modulation change queue, removing all pending changes.
 
void processAudio (AudioSampleBuffer *buffer, int channels, int samples, int offset)
 Processes audio into the given buffer. May be overridden or extended by subclasses.
 
void processAudioWithInput (AudioSampleBuffer *buffer, const vital::poly_float *input_buffer, int channels, int samples, int offset)
 Processes audio with an input buffer, often used for sidechain or feedback loops.
 
void writeAudio (AudioSampleBuffer *buffer, int channels, int samples, int offset)
 Writes audio data from the engine to the output buffer.
 
void processMidi (MidiBuffer &buffer, int start_sample=0, int end_sample=0)
 Processes MIDI messages from a MidiBuffer, applying them to the engine’s sound generation.
 
void processKeyboardEvents (MidiBuffer &buffer, int num_samples)
 Processes keyboard events from a MidiBuffer, integrating them with the MidiKeyboardState.
 
void processModulationChanges ()
 Processes pending modulation changes and updates the engine accordingly.
 
void updateMemoryOutput (int samples, const vital::poly_float *audio)
 Updates the oscilloscope memory with the latest audio samples.
 

Protected Attributes

std::unique_ptr< vital::SoundEngineengine_
 
std::unique_ptr< MidiManagermidi_manager_
 
std::unique_ptr< MidiKeyboardState > keyboard_state_
 
std::unique_ptr< WavetableCreatorwavetable_creators_ [vital::kNumOscillators]
 
std::shared_ptr< SynthBase * > self_reference_
 
File active_file_
 
vital::poly_float oscilloscope_memory_ [2 *vital::kOscilloscopeMemoryResolution]
 
vital::poly_float oscilloscope_memory_write_ [2 *vital::kOscilloscopeMemoryResolution]
 
std::unique_ptr< vital::StereoMemoryaudio_memory_
 
vital::mono_float last_played_note_
 
int last_num_pressed_
 
vital::mono_float memory_reset_period_
 
vital::mono_float memory_input_offset_
 
int memory_index_
 
bool expired_
 
std::map< std::string, String > save_info_
 
vital::control_map controls_
 
vital::CircularQueue< vital::ModulationConnection * > mod_connections_
 
moodycamel::ConcurrentQueue< vital::control_changevalue_change_queue_
 
moodycamel::ConcurrentQueue< vital::modulation_changemodulation_change_queue_
 
Tuning tuning_
 

Detailed Description

A base class providing foundational functionality for the Vital synthesizer’s engine, UI integration, modulation system, MIDI mapping, and preset management.

The SynthBase class:

  • Integrates a SoundEngine for audio generation and modulation.
  • Manages MIDI input through a MidiManager.
  • Maintains a set of controls (parameters) and handles parameter changes from GUI, MIDI, or code.
  • Supports loading/saving presets, wavetables, and other stateful elements.
  • Provides a queue-based system for thread-safe modulation and parameter changes.
  • Offers methods to render audio to disk, load tunings, and initiate default or user presets.

The class can be integrated with a GUI through a SynthGuiInterface or used headlessly (see HeadlessSynth). Subclasses must implement certain virtual methods to integrate with an audio processing environment.

Constructor & Destructor Documentation

◆ SynthBase()

SynthBase::SynthBase ( )

Constructs a SynthBase, initializing the sound engine, MIDI manager, wavetables, and settings.

◆ ~SynthBase()

SynthBase::~SynthBase ( )
virtual

Destroys the SynthBase, cleaning up resources such as sound engine and memory buffers.

Member Function Documentation

◆ armMidiLearn()

void SynthBase::armMidiLearn ( const std::string & name)

Arms the given parameter name for MIDI learn, associating the next received MIDI control with it.

Parameters
nameThe parameter name.

◆ beginChangeGesture()

virtual void SynthBase::beginChangeGesture ( const std::string & name)
inlinevirtual

Called when a parameter change gesture begins. Typically not implemented in this base class.

Parameters
nameThe parameter name.

Reimplemented in SynthPlugin.

◆ cancelMidiLearn()

void SynthBase::cancelMidiLearn ( )

Cancels a previously armed MIDI learn operation.

◆ checkOversampling()

void SynthBase::checkOversampling ( )

Checks and updates oversampling settings. May be called if parameters affecting oversampling change.

◆ clearActiveFile()

void SynthBase::clearActiveFile ( )
inline

Clears the currently active preset file, meaning changes are not saved to a previously loaded file.

◆ clearMidiLearn()

void SynthBase::clearMidiLearn ( const std::string & name)

Clears the MIDI mapping for a given parameter name.

Parameters
nameThe parameter to clear from MIDI mappings.

◆ clearModulationQueue()

void SynthBase::clearModulationQueue ( )
inlineprotected

Clears the modulation change queue, removing all pending changes.

◆ clearModulations()

void SynthBase::clearModulations ( )

Clears all modulation connections.

◆ connectModulation() [1/2]

bool SynthBase::connectModulation ( const std::string & source,
const std::string & destination )

Connects a modulation source to a destination parameter.

Parameters
sourceThe modulation source name.
destinationThe parameter name to modulate.
Returns
True if a new connection was created, false if it was already existing.

◆ connectModulation() [2/2]

void SynthBase::connectModulation ( vital::ModulationConnection * connection)

Connects a modulation using a pre-existing ModulationConnection object.

Parameters
connectionA pointer to the ModulationConnection object to be connected.

◆ createModulationChange()

vital::modulation_change SynthBase::createModulationChange ( vital::ModulationConnection * connection)
protected

Creates a modulation_change structure for a given connection, preparing it for engine operations.

Parameters
connectionA pointer to a ModulationConnection.
Returns
A modulation_change object describing the connection.

◆ disconnectModulation() [1/2]

void SynthBase::disconnectModulation ( const std::string & source,
const std::string & destination )

Disconnects a modulation source from a destination parameter.

Parameters
sourceThe modulation source name.
destinationThe parameter name.

◆ disconnectModulation() [2/2]

void SynthBase::disconnectModulation ( vital::ModulationConnection * connection)

Disconnects a modulation given a ModulationConnection object.

Parameters
connectionThe ModulationConnection to disconnect.

◆ endChangeGesture()

virtual void SynthBase::endChangeGesture ( const std::string & name)
inlinevirtual

Called when a parameter change gesture ends. Typically not implemented in this base class.

Parameters
nameThe parameter name.

Reimplemented in SynthPlugin.

◆ forceShowModulation()

void SynthBase::forceShowModulation ( const std::string & source,
bool force )

Forces a modulation source to remain active even if not currently connected.

Parameters
sourceThe modulation source.
forceTrue to keep it active, false to allow disabling.

◆ getActiveFile()

File SynthBase::getActiveFile ( )
inline

Gets the currently active preset file.

Returns
The active File object.

◆ getAudioMemory()

const vital::StereoMemory * SynthBase::getAudioMemory ( )
inline

Retrieves stereo memory holding recent audio output samples for visualization.

Returns
A pointer to the StereoMemory object.

◆ getAuthor()

String SynthBase::getAuthor ( )

Gets the author of the current preset.

Returns
The author’s name as a String.

◆ getComments()

String SynthBase::getComments ( )

Gets the comments for the current preset.

Returns
The comments string.

◆ getConnection()

vital::ModulationConnection * SynthBase::getConnection ( const std::string & source,
const std::string & destination )
protected

Finds a ModulationConnection by source and destination names.

Parameters
sourceThe modulation source name.
destinationThe parameter destination name.
Returns
A pointer to the ModulationConnection, or nullptr if not found.

◆ getConnectionIndex()

int SynthBase::getConnectionIndex ( const std::string & source,
const std::string & destination )

Gets the index of a modulation connection given its source and destination.

Parameters
sourceThe modulation source.
destinationThe parameter destination.
Returns
The index or -1 if not found.

◆ getControls()

vital::control_map & SynthBase::getControls ( )
inline

Provides access to the controls map (parameter name to Parameter pointer).

Returns
A reference to the control_map.

◆ getCriticalSection()

virtual const CriticalSection & SynthBase::getCriticalSection ( )
pure virtual

Provides access to the synth’s internal CriticalSection for thread safety.

Must be implemented by subclasses.

Returns
A reference to the CriticalSection.

Implemented in HeadlessSynth, SynthEditor, and SynthPlugin.

◆ getDestinationConnections()

std::vector< vital::ModulationConnection * > SynthBase::getDestinationConnections ( const std::string & destination)

Returns all modulation connections targeting a given destination parameter.

Parameters
destinationThe parameter name.
Returns
A vector of ModulationConnection pointers.

◆ getEngine()

vital::SoundEngine * SynthBase::getEngine ( )
inline

Returns a pointer to the SoundEngine used for audio and modulation processing.

Returns
A pointer to the SoundEngine.

◆ getEqualizerMemory()

const vital::StereoMemory * SynthBase::getEqualizerMemory ( )

Retrieves memory used for equalizer visualization, if available.

Returns
A pointer to the StereoMemory for the equalizer, or nullptr if not available.

◆ getGuiInterface()

virtual SynthGuiInterface * SynthBase::getGuiInterface ( )
protectedpure virtual

Retrieves the GUI interface if available, for updating controls or notifications.

Returns
A pointer to a SynthGuiInterface, or nullptr if headless.

Implemented in HeadlessSynth, SynthEditor, and SynthPlugin.

◆ getKeyboardState()

MidiKeyboardState * SynthBase::getKeyboardState ( )
inline

Retrieves the keyboard state (for processing MIDI note events from a virtual keyboard).

Returns
A pointer to the MidiKeyboardState.

◆ getLfoSource()

LineGenerator * SynthBase::getLfoSource ( int index)

Retrieves an LFO source by index.

Parameters
indexThe LFO index.
Returns
A pointer to the LFO’s LineGenerator object.

◆ getMacroName()

String SynthBase::getMacroName ( int index)

Gets the name of a macro control by index.

Parameters
indexThe macro index (0-based).
Returns
The macro name.

◆ getModulationBank()

vital::ModulationConnectionBank & SynthBase::getModulationBank ( )

Retrieves the ModulationConnectionBank managing all modulation connections.

Returns
A reference to the ModulationConnectionBank.

◆ getModulationConnections()

vital::CircularQueue< vital::ModulationConnection * > SynthBase::getModulationConnections ( )
inline

Gets all current modulation connections as a CircularQueue.

Returns
A queue of pointers to ModulationConnection objects.

◆ getNextModulationChange()

bool SynthBase::getNextModulationChange ( vital::modulation_change & change)
inlineprotected

Attempts to dequeue a modulation_change for processing.

Parameters
changeA reference to store the dequeued change.
Returns
True if a change was dequeued, false otherwise.

◆ getNumModulations()

int SynthBase::getNumModulations ( const std::string & destination)

Counts how many modulations target a given parameter.

Parameters
destinationThe parameter name.
Returns
The number of modulations.

◆ getOscilloscopeMemory()

const vital::poly_float * SynthBase::getOscilloscopeMemory ( )
inline

Retrieves the oscilloscope memory for visualization of audio output waveforms.

Returns
A pointer to an array of poly_float samples representing the oscilloscope memory.

◆ getPresetName()

String SynthBase::getPresetName ( )

Gets the current preset’s name.

Returns
The preset name.

◆ getSample()

vital::Sample * SynthBase::getSample ( )

Gets the Sample object used by the engine.

Returns
A pointer to the Sample.

◆ getSampleRate()

int SynthBase::getSampleRate ( )

Retrieves the current audio sample rate used by the engine.

Returns
The sample rate in Hz.

◆ getSourceConnections()

std::vector< vital::ModulationConnection * > SynthBase::getSourceConnections ( const std::string & source)

Returns all modulation connections from a particular source.

Parameters
sourceThe modulation source.
Returns
A vector of ModulationConnection pointers.

◆ getStatusOutput()

const vital::StatusOutput * SynthBase::getStatusOutput ( const std::string & name)

Retrieves a status output by name.

Parameters
nameThe status output name.
Returns
A pointer to the StatusOutput, or nullptr if not found.

◆ getStyle()

String SynthBase::getStyle ( )

Gets the style of the current preset.

Returns
The style string.

◆ getTuning()

Tuning * SynthBase::getTuning ( )
inline

Returns a pointer to the synth's Tuning object.

Returns
A pointer to the Tuning.

◆ getWavetable()

vital::Wavetable * SynthBase::getWavetable ( int index)

Gets a wavetable object from the engine.

Parameters
indexThe oscillator index.
Returns
A pointer to the Wavetable.

◆ getWavetableCreator()

WavetableCreator * SynthBase::getWavetableCreator ( int index)

Gets a WavetableCreator for a given oscillator index.

Parameters
indexThe oscillator index.
Returns
A pointer to the WavetableCreator.

◆ initEngine()

void SynthBase::initEngine ( )

Initializes the engine to a default state, clearing modulations and resetting parameters.

◆ isInvalidConnection()

bool SynthBase::isInvalidConnection ( const vital::modulation_change & change)
protected

Checks if a modulation_change is invalid (e.g., creates a loop).

Parameters
changeThe modulation_change object to check.
Returns
True if invalid, false otherwise.

◆ isMidiMapped()

bool SynthBase::isMidiMapped ( const std::string & name)

Checks if a given parameter name is MIDI mapped.

Parameters
nameThe parameter name.
Returns
True if mapped, false otherwise.

◆ isModSourceEnabled()

bool SynthBase::isModSourceEnabled ( const std::string & source)

Checks if a modulation source is currently enabled.

Parameters
sourceThe modulation source name.
Returns
True if enabled, false otherwise.

◆ isSourceConnected()

bool SynthBase::isSourceConnected ( const std::string & source)

Checks if a given modulation source has any active connections.

Parameters
sourceThe modulation source.
Returns
True if the source is connected, false otherwise.

◆ loadFromFile()

bool SynthBase::loadFromFile ( File preset,
std::string & error )

Attempts to load a preset from a file.

Parameters
presetThe preset file.
errorA string to store error messages if loading fails.
Returns
True if successful, false otherwise.

◆ loadFromJson()

bool SynthBase::loadFromJson ( const json & state)
protected

Deserializes and applies the synth state from a JSON object.

Parameters
stateThe JSON object to load.
Returns
True if successful, false if incompatible.

◆ loadInitPreset()

void SynthBase::loadInitPreset ( )

Loads an "init" preset, resetting Vital to its default initial state.

◆ loadTuningFile()

void SynthBase::loadTuningFile ( const File & file)

Loads a tuning file into the synthesizer’s tuning system.

Parameters
fileThe File representing the tuning.

◆ modWheelGuiChanged()

void SynthBase::modWheelGuiChanged ( vital::mono_float value)

Called when the mod wheel changes via the GUI or another external source.

Parameters
valueThe new mod wheel value.

◆ modWheelMidiChanged()

void SynthBase::modWheelMidiChanged ( vital::mono_float value)
overridevirtual

Called when the mod wheel value changes via MIDI.

Parameters
valueThe new mod wheel value.

Implements MidiManager::Listener.

◆ notifyOversamplingChanged()

void SynthBase::notifyOversamplingChanged ( )

Notifies that oversampling settings have changed, reinitializing the engine if needed.

◆ pauseProcessing()

virtual void SynthBase::pauseProcessing ( bool pause)
pure virtual

Pauses or resumes audio processing.

When paused, processing locks the critical section to avoid concurrency issues.

Parameters
pauseTrue to pause, false to resume.

Implemented in HeadlessSynth, SynthEditor, and SynthPlugin.

◆ pitchWheelGuiChanged()

void SynthBase::pitchWheelGuiChanged ( vital::mono_float value)

Called when the pitch wheel changes via the GUI or another external source.

Parameters
valueThe new pitch wheel value.

◆ pitchWheelMidiChanged()

void SynthBase::pitchWheelMidiChanged ( vital::mono_float value)
overridevirtual

Called when the pitch wheel value changes via MIDI.

Parameters
valueThe new pitch wheel value.

Implements MidiManager::Listener.

◆ presetChangedThroughMidi()

void SynthBase::presetChangedThroughMidi ( File preset)
overridevirtual

Called when a preset is changed through MIDI (e.g., program change messages).

Parameters
presetThe new preset file.

Implements MidiManager::Listener.

◆ processAudio()

void SynthBase::processAudio ( AudioSampleBuffer * buffer,
int channels,
int samples,
int offset )
protected

Processes audio into the given buffer. May be overridden or extended by subclasses.

Parameters
bufferPointer to the output AudioSampleBuffer.
channelsNumber of output channels.
samplesNumber of samples to process.
offsetSample offset in the output buffer.

◆ processAudioWithInput()

void SynthBase::processAudioWithInput ( AudioSampleBuffer * buffer,
const vital::poly_float * input_buffer,
int channels,
int samples,
int offset )
protected

Processes audio with an input buffer, often used for sidechain or feedback loops.

Parameters
bufferThe output buffer.
input_bufferA pointer to the input poly_float buffer.
channelsNumber of output channels.
samplesNumber of samples to process.
offsetSample offset in the output buffer.

◆ processKeyboardEvents()

void SynthBase::processKeyboardEvents ( MidiBuffer & buffer,
int num_samples )
protected

Processes keyboard events from a MidiBuffer, integrating them with the MidiKeyboardState.

Parameters
bufferThe MidiBuffer with keyboard messages.
num_samplesThe number of samples to process.

◆ processMidi()

void SynthBase::processMidi ( MidiBuffer & buffer,
int start_sample = 0,
int end_sample = 0 )
protected

Processes MIDI messages from a MidiBuffer, applying them to the engine’s sound generation.

Parameters
bufferThe MidiBuffer containing MIDI messages.
start_sampleThe starting sample to process MIDI for.
end_sampleThe ending sample (0 means process all).

◆ processModulationChanges()

void SynthBase::processModulationChanges ( )
protected

Processes pending modulation changes and updates the engine accordingly.

◆ renderAudioForResynthesis()

void SynthBase::renderAudioForResynthesis ( float * data,
int samples,
int note )

Renders audio for the purpose of resynthesis into a provided buffer.

Parameters
dataPointer to a float array to store samples.
samplesThe number of samples to render.
noteThe MIDI note to play for resynthesis.

◆ renderAudioToFile()

void SynthBase::renderAudioToFile ( File file,
float seconds,
float bpm,
std::vector< int > notes,
bool render_images )

Renders audio to a WAV file for a given duration and note sequence.

Parameters
fileThe output WAV file.
secondsThe duration in seconds.
bpmThe tempo in beats per minute.
notesA vector of MIDI notes to play.
render_imagesWhether to render oscilloscope images alongside.

◆ saveToActiveFile()

bool SynthBase::saveToActiveFile ( )

Saves the current preset state to the active file (if any).

Returns
True if successful, false otherwise.

◆ saveToFile()

bool SynthBase::saveToFile ( File preset)

Saves the current preset state to the specified file.

Parameters
presetThe file to save to (the extension is enforced).
Returns
True if the save was successful, false otherwise.

◆ saveToJson()

json SynthBase::saveToJson ( )
protected

Serializes the current synth state into a JSON object.

Returns
A JSON object representing the synth’s state.

◆ setAuthor()

void SynthBase::setAuthor ( const String & author)

Sets the author metadata of the current preset.

Parameters
authorThe author's name.

◆ setComments()

void SynthBase::setComments ( const String & comments)

Sets the comments or description metadata of the current preset.

Parameters
commentsThe comments string.

◆ setMacroName()

void SynthBase::setMacroName ( int index,
const String & macro_name )

Sets the name of a macro control by index.

Parameters
indexThe macro index (0-based).
macro_nameThe macro name as a String.

◆ setMpeEnabled()

void SynthBase::setMpeEnabled ( bool enabled)

Enables or disables MPE (MIDI Polyphonic Expression) mode.

Parameters
enabledTrue to enable MPE, false to disable.

◆ setPresetName()

void SynthBase::setPresetName ( const String & preset_name)

Sets the preset name.

Parameters
preset_nameThe preset name as a String.

◆ setStyle()

void SynthBase::setStyle ( const String & style)

Sets the style metadata of the current preset (e.g., bass, lead, etc.).

Parameters
styleThe style description string.

◆ setValueNotifyHost()

virtual void SynthBase::setValueNotifyHost ( const std::string & name,
vital::mono_float value )
inlinevirtual

Called when a parameter changes to notify a potential host environment. Typically not implemented here.

Parameters
nameThe parameter name.
valueThe new parameter value.

Reimplemented in SynthPlugin.

◆ updateMemoryOutput()

void SynthBase::updateMemoryOutput ( int samples,
const vital::poly_float * audio )
protected

Updates the oscilloscope memory with the latest audio samples.

Parameters
samplesNumber of samples processed.
audioPointer to the audio sample data.

◆ valueChanged()

void SynthBase::valueChanged ( const std::string & name,
vital::mono_float value )

Updates the value of a control parameter.

Parameters
nameThe name of the parameter.
valueThe new value.

◆ valueChangedExternal()

void SynthBase::valueChangedExternal ( const std::string & name,
vital::mono_float value )

Handles external (non-GUI, non-MIDI) value changes to parameters.

Parameters
nameThe parameter name.
valueThe new value.

◆ valueChangedInternal()

void SynthBase::valueChangedInternal ( const std::string & name,
vital::mono_float value )

Handles internal value changes, updating the parameter and optionally notifying the host.

Parameters
nameThe parameter name.
valueThe new parameter value.

◆ valueChangedThroughMidi()

void SynthBase::valueChangedThroughMidi ( const std::string & name,
vital::mono_float value )
overridevirtual

Handles parameter changes triggered through MIDI mappings.

Parameters
nameThe name of the parameter.
valueThe new parameter value.

Implements MidiManager::Listener.

◆ writeAudio()

void SynthBase::writeAudio ( AudioSampleBuffer * buffer,
int channels,
int samples,
int offset )
protected

Writes audio data from the engine to the output buffer.

Parameters
bufferThe output AudioSampleBuffer.
channelsNumber of output channels.
samplesNumber of samples to write.
offsetThe sample offset in the output buffer.

Member Data Documentation

◆ active_file_

File SynthBase::active_file_
protected

◆ audio_memory_

std::unique_ptr<vital::StereoMemory> SynthBase::audio_memory_
protected

◆ controls_

vital::control_map SynthBase::controls_
protected

◆ engine_

std::unique_ptr<vital::SoundEngine> SynthBase::engine_
protected

◆ expired_

bool SynthBase::expired_
protected

◆ keyboard_state_

std::unique_ptr<MidiKeyboardState> SynthBase::keyboard_state_
protected

◆ kOutputWindowMaxNote

float SynthBase::kOutputWindowMaxNote = 128.0f
staticconstexpr

◆ kOutputWindowMinNote

float SynthBase::kOutputWindowMinNote = 16.0f
staticconstexpr

Minimum and maximum note values considered for output window display or related processing.

◆ last_num_pressed_

int SynthBase::last_num_pressed_
protected

◆ last_played_note_

vital::mono_float SynthBase::last_played_note_
protected

◆ memory_index_

int SynthBase::memory_index_
protected

◆ memory_input_offset_

vital::mono_float SynthBase::memory_input_offset_
protected

◆ memory_reset_period_

vital::mono_float SynthBase::memory_reset_period_
protected

◆ midi_manager_

std::unique_ptr<MidiManager> SynthBase::midi_manager_
protected

◆ mod_connections_

vital::CircularQueue<vital::ModulationConnection*> SynthBase::mod_connections_
protected

◆ modulation_change_queue_

moodycamel::ConcurrentQueue<vital::modulation_change> SynthBase::modulation_change_queue_
protected

◆ oscilloscope_memory_

vital::poly_float SynthBase::oscilloscope_memory_[2 *vital::kOscilloscopeMemoryResolution]
protected

◆ oscilloscope_memory_write_

vital::poly_float SynthBase::oscilloscope_memory_write_[2 *vital::kOscilloscopeMemoryResolution]
protected

◆ save_info_

std::map<std::string, String> SynthBase::save_info_
protected

◆ self_reference_

std::shared_ptr<SynthBase*> SynthBase::self_reference_
protected

◆ tuning_

Tuning SynthBase::tuning_
protected

◆ value_change_queue_

moodycamel::ConcurrentQueue<vital::control_change> SynthBase::value_change_queue_
protected

◆ wavetable_creators_

std::unique_ptr<WavetableCreator> SynthBase::wavetable_creators_[vital::kNumOscillators]
protected

The documentation for this class was generated from the following files: