Vital
|
Core class responsible for handling note events, oversampling, and the main effects chain. More...
#include <sound_engine.h>
Public Member Functions | |
SoundEngine () | |
Constructs a SoundEngine and initializes internal state and controls. | |
virtual | ~SoundEngine () |
Destroys the SoundEngine, cleaning up submodules and modulation resources. | |
void | init () override |
Initializes the engine by creating base controls and submodules (effects chain, etc.). | |
void | processWithInput (const poly_float *audio_in, int num_samples) override |
Processes a block of samples using the current state of the SoundEngine. | |
void | correctToTime (double seconds) override |
Synchronizes all time-based modules to a given time, e.g. for timeline-based automation. | |
int | getNumPressedNotes () |
Returns the number of currently pressed notes across all channels. | |
void | connectModulation (const modulation_change &change) |
Connects a modulation source to a destination via the given modulation_change structure. | |
void | disconnectModulation (const modulation_change &change) |
Disconnects a previously established modulation route. | |
int | getNumActiveVoices () |
Returns the number of active voices in the engine. | |
ModulationConnectionBank & | getModulationBank () |
Provides access to the internal ModulationConnectionBank for managing mod routes. | |
mono_float | getLastActiveNote () const |
Retrieves the most recently active note number. | |
void | setTuning (const Tuning *tuning) |
Sets a custom Tuning object for note-to-frequency mapping. | |
void | setOversamplingAmount (int oversampling_amount, int sample_rate) |
Configures the engine’s oversampling factor and sample rate. | |
void | allSoundsOff () override |
Stops and resets all currently playing notes and any lingering states in the effect chain. | |
void | allNotesOff (int sample) override |
Turns off all notes on all channels at the specified sample index. | |
void | allNotesOff (int sample, int channel) override |
Turns off all notes on a specific channel at a given sample. | |
void | allNotesOffRange (int sample, int from_channel, int to_channel) |
Turns off all notes within a range of channels. | |
void | noteOn (int note, mono_float velocity, int sample, int channel) override |
Handles a note-on event, triggering the engine’s voice handling. | |
void | noteOff (int note, mono_float lift, int sample, int channel) override |
Handles a note-off event, releasing the voice allocated to the note. | |
void | setModWheel (mono_float value, int channel) |
Sets the mod wheel value for a given MIDI channel. | |
void | setModWheelAllChannels (mono_float value) |
Sets the mod wheel value for all MIDI channels. | |
void | setPitchWheel (mono_float value, int channel) |
Sets the pitch wheel value for a specified MIDI channel. | |
void | setZonedPitchWheel (mono_float value, int from_channel, int to_channel) |
Applies a pitch wheel value to a range of MIDI channels. | |
void | disableUnnecessaryModSources () |
Disables unnecessary modulation sources in the engine to save CPU. | |
void | enableModSource (const std::string &source) |
Enables a specific named modulation source by making its owner active. | |
void | disableModSource (const std::string &source) |
Disables a specific named modulation source. | |
bool | isModSourceEnabled (const std::string &source) |
Checks if a given named modulation source is currently enabled. | |
const StereoMemory * | getEqualizerMemory () |
Retrieves the internal equalizer memory (used for certain effect processing). | |
void | setBpm (mono_float bpm) |
Updates the engine’s tempo in BPM, converting to beats per second for internal usage. | |
void | setAftertouch (mono_float note, mono_float value, int sample, int channel) |
Sets polyphonic aftertouch for a specific note on a given channel. | |
void | setChannelAftertouch (int channel, mono_float value, int sample) |
Sets channel-wide aftertouch on a given channel. | |
void | setChannelRangeAftertouch (int from_channel, int to_channel, mono_float value, int sample) |
Applies aftertouch to all channels in a specified range. | |
void | setChannelSlide (int channel, mono_float value, int sample) |
Sets channel slide (e.g., an expression or glide parameter) on a specific channel. | |
void | setChannelRangeSlide (int from_channel, int to_channel, mono_float value, int sample) |
Applies channel slide to all channels in a specified range. | |
Wavetable * | getWavetable (int index) |
Retrieves a pointer to a Wavetable by index (not implemented here). | |
Sample * | getSample () |
Retrieves a pointer to a Sample object (not implemented here). | |
LineGenerator * | getLfoSource (int index) |
Retrieves a pointer to the LFO source line generator for the given index. | |
void | sustainOn (int channel) |
Engages sustain on a single MIDI channel (holding all pressed notes). | |
void | sustainOff (int sample, int channel) |
Disengages sustain on a single MIDI channel, releasing notes if their keys are up. | |
void | sostenutoOn (int channel) |
Engages sostenuto on a single MIDI channel (holding only currently pressed notes). | |
void | sostenutoOff (int sample, int channel) |
Disengages sostenuto on a single MIDI channel. | |
void | sustainOnRange (int from_channel, int to_channel) |
Engages sustain on a range of MIDI channels. | |
void | sustainOffRange (int sample, int from_channel, int to_channel) |
Disengages sustain on a range of MIDI channels. | |
void | sostenutoOnRange (int from_channel, int to_channel) |
Engages sostenuto on a range of MIDI channels. | |
void | sostenutoOffRange (int sample, int from_channel, int to_channel) |
Disengages sostenuto on a range of MIDI channels. | |
force_inline int | getOversamplingAmount () const |
Retrieves the current oversampling factor (e.g., 1, 2, 4). | |
void | checkOversampling () |
Checks if the oversampling setting or sample rate has changed, and reconfigures if needed. | |
SoundEngine () | |
Constructs a new SoundEngine instance. | |
virtual | ~SoundEngine () |
Destroys the SoundEngine instance. | |
void | init () override |
Initializes the SoundEngine, setting up controls, voices, and effects. | |
void | process (int num_samples) override |
Processes a block of samples through the voice handler and effects chain. | |
void | correctToTime (double seconds) override |
Corrects internal timing to a given absolute time in seconds. | |
int | getNumPressedNotes () |
Gets the number of currently pressed notes. | |
void | connectModulation (const modulation_change &change) |
Connects a modulation source to its destination. | |
void | disconnectModulation (const modulation_change &change) |
Disconnects a previously connected modulation source from its destination. | |
int | getNumActiveVoices () |
Gets the number of currently active voices. | |
ModulationConnectionBank & | getModulationBank () |
Gets the modulation connection bank for this engine. | |
mono_float | getLastActiveNote () const |
Gets the last active note played. | |
void | setTuning (const Tuning *tuning) |
Sets the tuning to use for pitch calculations. | |
void | allSoundsOff () override |
Turns off all sounds immediately. | |
void | allNotesOff (int sample) override |
Sends all voices a note-off command at a given sample. | |
void | allNotesOff (int sample, int channel) override |
Sends all voices on a given channel a note-off command. | |
void | allNotesOffRange (int sample, int from_channel, int to_channel) |
Sends all voices in a range of channels a note-off command. | |
void | noteOn (int note, mono_float velocity, int sample, int channel) override |
Triggers a note-on event. | |
void | noteOff (int note, mono_float lift, int sample, int channel) override |
Triggers a note-off event. | |
void | setModWheel (mono_float value, int channel) |
Sets the modulation wheel value for a given channel. | |
void | setModWheelAllChannels (mono_float value) |
Sets the modulation wheel value for all channels. | |
void | setPitchWheel (mono_float value, int channel) |
Sets the pitch wheel value for a given channel. | |
void | setZonedPitchWheel (mono_float value, int from_channel, int to_channel) |
Sets the pitch wheel value for a range of channels. | |
void | disableUnnecessaryModSources () |
Disables any modulation sources that are not required. | |
void | enableModSource (const std::string &source) |
Enables a modulation source by name. | |
void | disableModSource (const std::string &source) |
Disables a modulation source by name. | |
bool | isModSourceEnabled (const std::string &source) |
Checks if a modulation source is enabled. | |
const StereoMemory * | getEqualizerMemory () |
Gets a pointer to the stereo memory used by the equalizer. | |
void | setBpm (mono_float bpm) |
Sets the BPM (beats per minute) value for the engine. | |
void | setAftertouch (mono_float note, mono_float value, int sample, int channel) |
Sets note-based aftertouch values. | |
void | setChannelAftertouch (int channel, mono_float value, int sample) |
Sets aftertouch values for an entire channel. | |
void | setChannelRangeAftertouch (int from_channel, int to_channel, mono_float value, int sample) |
Sets aftertouch values for a range of channels. | |
void | setChannelSlide (int channel, mono_float value, int sample) |
Sets channel-based slide (MPE/MIDI CC glides). | |
void | setChannelRangeSlide (int from_channel, int to_channel, mono_float value, int sample) |
Sets slide values for a range of channels. | |
Wavetable * | getWavetable (int index) |
Gets a pointer to a wavetable by index. | |
Sample * | getSample () |
Gets a pointer to the Sample object. | |
LineGenerator * | getLfoSource (int index) |
Gets a pointer to an LFO source by index. | |
void | sustainOn (int channel) |
Turns sustain on for a given channel. | |
void | sustainOff (int sample, int channel) |
Turns sustain off for a given channel at a specific sample. | |
void | sostenutoOn (int channel) |
Turns sostenuto on for a given channel. | |
void | sostenutoOff (int sample, int channel) |
Turns sostenuto off for a given channel at a specific sample. | |
void | sustainOnRange (int from_channel, int to_channel) |
Turns sustain on for a range of channels. | |
void | sustainOffRange (int sample, int from_channel, int to_channel) |
Turns sustain off for a range of channels at a given sample. | |
void | sostenutoOnRange (int from_channel, int to_channel) |
Turns sostenuto on for a range of channels. | |
void | sostenutoOffRange (int sample, int from_channel, int to_channel) |
Turns sostenuto off for a range of channels at a given sample. | |
force_inline int | getOversamplingAmount () const |
Gets the current oversampling amount. | |
void | checkOversampling () |
Checks if the oversampling settings have changed and updates accordingly. | |
![]() | |
SynthModule (int num_inputs, int num_outputs, bool control_rate=false) | |
Constructs a SynthModule with specified I/O and control rate. | |
virtual | ~SynthModule () |
Destructor. | |
control_map | getControls () |
Returns a map of all controls from this module and its submodules. | |
Output * | getModulationSource (std::string name) |
Retrieves a modulation source output by name. | |
const StatusOutput * | getStatusOutput (std::string name) const |
Retrieves a StatusOutput by name. | |
Processor * | getModulationDestination (std::string name, bool poly) |
Retrieves a modulation destination Processor by name and poly mode. | |
Processor * | getMonoModulationDestination (std::string name) |
Retrieves a mono modulation destination by name. | |
Processor * | getPolyModulationDestination (std::string name) |
Retrieves a poly modulation destination by name. | |
ValueSwitch * | getModulationSwitch (std::string name, bool poly) |
Retrieves a modulation switch by name and poly mode. | |
ValueSwitch * | getMonoModulationSwitch (std::string name) |
Retrieves a mono modulation switch by name. | |
ValueSwitch * | getPolyModulationSwitch (std::string name) |
Retrieves a poly modulation switch by name. | |
void | updateAllModulationSwitches () |
Updates all modulation switches based on whether their destinations have inputs. | |
output_map & | getModulationSources () |
Returns a reference to the map of modulation sources. | |
input_map & | getMonoModulationDestinations () |
Returns a reference to the map of mono modulation destinations. | |
input_map & | getPolyModulationDestinations () |
Returns a reference to the map of poly modulation destinations. | |
virtual output_map & | getMonoModulations () |
Returns a reference to the map of mono modulation readouts. | |
virtual output_map & | getPolyModulations () |
Returns a reference to the map of poly modulation readouts. | |
void | enableOwnedProcessors (bool enable) |
Enables or disables all owned processors. | |
virtual void | enable (bool enable) override |
Enables or disables this SynthModule and its owned processors. | |
void | addMonoProcessor (Processor *processor, bool own=true) |
Adds a mono processor to this module. | |
void | addIdleMonoProcessor (Processor *processor) |
Adds a mono processor that is considered idle (not part of main processing chain). | |
virtual Processor * | clone () const override |
Clones this SynthModule. | |
void | addSubmodule (SynthModule *module) |
Adds a submodule to this SynthModule. | |
![]() | |
ProcessorRouter (int num_inputs=0, int num_outputs=0, bool control_rate=false) | |
Constructs a ProcessorRouter with a specified number of inputs and outputs. | |
ProcessorRouter (const ProcessorRouter &original) | |
Copy constructor. Creates a new ProcessorRouter from an existing one. | |
virtual | ~ProcessorRouter () |
Destructor. | |
virtual void | setSampleRate (int sample_rate) override |
Sets the sample rate for all Processors in this router. | |
virtual void | setOversampleAmount (int oversample) override |
Sets the oversampling amount for all Processors in this router. | |
virtual void | addProcessor (Processor *processor) |
Adds a Processor to be managed by this router. | |
virtual void | addProcessorRealTime (Processor *processor) |
Adds a Processor to the router in real-time (no memory allocations). | |
virtual void | addIdleProcessor (Processor *processor) |
Adds a Processor that should remain idle (not processed) in the router. | |
virtual void | removeProcessor (Processor *processor) |
Removes a Processor from this router. | |
void | connect (Processor *destination, const Output *source, int index) |
Connects a source Output to a destination Processor input by index. | |
void | disconnect (const Processor *destination, const Output *source) |
Disconnects a source Output from a destination Processor. | |
bool | isDownstream (const Processor *first, const Processor *second) const |
Checks if one Processor is downstream from another, i.e., if there's a path from the second to the first. | |
bool | areOrdered (const Processor *first, const Processor *second) const |
Checks if the order of two Processors is fixed in the router's processing sequence. | |
virtual bool | isPolyphonic (const Processor *processor) const |
Determines if a given Processor is polyphonic within this router. | |
virtual ProcessorRouter * | getMonoRouter () |
Gets the mono router that corresponds to this ProcessorRouter. | |
virtual ProcessorRouter * | getPolyRouter () |
Gets the polyphonic router that corresponds to this ProcessorRouter. | |
virtual void | resetFeedbacks (poly_mask reset_mask) |
Resets all Feedback nodes within this router using a reset mask. | |
![]() | |
Processor (int num_inputs, int num_outputs, bool control_rate=false, int max_oversample=1) | |
Constructs a Processor with a given number of inputs/outputs and oversampling. | |
virtual | ~Processor () |
Virtual destructor. | |
virtual bool | hasState () const |
Indicates whether this Processor requires per-voice state. | |
virtual void | reset (poly_mask reset_mask) |
Called to reset the Processor's per-voice state (e.g., on note-on). | |
virtual void | hardReset () |
Called to perform a "hard" reset for all voices. | |
bool | initialized () |
Returns whether this Processor has been initialized. | |
force_inline bool | enabled () const |
Checks if this Processor is enabled. | |
force_inline int | getSampleRate () const |
Retrieves the current (effective) sample rate. | |
force_inline int | getOversampleAmount () const |
Retrieves the current oversampling factor. | |
force_inline bool | isControlRate () const |
Checks if this Processor is running at control rate (buffer_size == 1). | |
virtual void | setControlRate (bool control_rate) |
Sets whether this Processor runs at control rate. | |
force_inline poly_mask | getResetMask (int input_index) const |
Retrieves a mask indicating which voices triggered a note-on event. Compares the input's trigger_value to kVoiceOn. | |
force_inline void | clearOutputBufferForReset (poly_mask reset_mask, int input_index, int output_index) const |
Clears output samples for voices that are about to be reset, based on the trigger offset. | |
bool | inputMatchesBufferSize (int input=0) |
Checks whether the buffer size of a particular input matches the size needed by this Processor. | |
bool | checkInputAndOutputSize (int num_samples) |
Checks if all inputs and outputs have buffers big enough for num_samples . | |
virtual bool | isPolyphonic () const |
Checks if this Processor is polyphonic by querying its ProcessorRouter. | |
void | plug (const Output *source) |
Connects an external Output to this Processor's first input. | |
void | plug (const Output *source, unsigned int input_index) |
Connects an external Output to a specified input index. | |
void | plug (const Processor *source) |
Connects the first output of a Processor to this Processor's first input. | |
void | plug (const Processor *source, unsigned int input_index) |
Connects the first output of a Processor to a specified input index. | |
void | plugNext (const Output *source) |
Connects an external Output to the first available (unplugged) input. | |
void | plugNext (const Processor *source) |
Connects the first output of a Processor to the first available (unplugged) input. | |
void | useInput (Input *input) |
Uses an existing Input object as this Processor's first input. | |
void | useInput (Input *input, int index) |
Uses an existing Input object at a specified input index. | |
void | useOutput (Output *output) |
Uses an existing Output object as this Processor's first output. | |
void | useOutput (Output *output, int index) |
Uses an existing Output object at a specified output index. | |
int | connectedInputs () |
Counts how many inputs are connected to a real source (not null_source_). | |
virtual void | unplugIndex (unsigned int input_index) |
Removes the connection at a specified input index, if any. | |
virtual void | unplug (const Output *source) |
Removes a connection to a given Output from all inputs. | |
virtual void | unplug (const Processor *source) |
Removes connections to all outputs from a given Processor. | |
virtual void | numInputsChanged () |
Called when the number of inputs changes (e.g., new connections). Subclasses may override for dynamic behavior. | |
force_inline void | router (ProcessorRouter *router) |
Sets the ProcessorRouter that owns or manages this Processor. | |
force_inline ProcessorRouter * | router () const |
Returns the ProcessorRouter that currently owns this Processor. | |
ProcessorRouter * | getTopLevelRouter () const |
Gets the topmost (root) ProcessorRouter by traversing parent routers. | |
virtual void | registerInput (Input *input, int index) |
Registers a new input, appending it to the input list. | |
virtual Output * | registerOutput (Output *output, int index) |
Registers a new Output in the output list at a specified index. | |
virtual void | registerInput (Input *input) |
Registers a new Input by appending it to the end of the input list. | |
virtual Output * | registerOutput (Output *output) |
Registers a new Output by appending it to the end of the output list. | |
force_inline int | numInputs () const |
Returns the total number of Input pointers (owned or otherwise). | |
force_inline int | numOutputs () const |
Returns the total number of Output pointers (owned or otherwise). | |
force_inline int | numOwnedInputs () const |
Returns how many Input objects this Processor owns. | |
force_inline int | numOwnedOutputs () const |
Returns how many Output objects this Processor owns. | |
force_inline Input * | input (unsigned int index=0) const |
Retrieves the Input pointer at a given index. | |
force_inline bool | isInputSourcePolyphonic (int index=0) |
Checks if the input source at a given index is polyphonic. | |
force_inline Input * | ownedInput (unsigned int index=0) const |
Retrieves an owned Input pointer at a given index. | |
force_inline Output * | output (unsigned int index=0) const |
Retrieves the Output pointer at a given index. | |
force_inline Output * | ownedOutput (unsigned int index=0) const |
Retrieves an owned Output pointer at a given index. | |
void | setPluggingStart (int start) |
Sets the position at which plugNext starts searching for an open input. | |
![]() | |
virtual | ~NoteHandler () |
Virtual destructor. | |
Static Public Attributes | |
static constexpr int | kDefaultOversamplingAmount = 2 |
Default oversampling factor. | |
static constexpr int | kDefaultSampleRate = 44100 |
Default sample rate used before explicit configuration. | |
Additional Inherited Members | |
![]() | |
Value * | createBaseControl (std::string name, bool audio_rate=false, bool smooth_value=false) |
Creates a simple control processor for a given parameter name. | |
Output * | createBaseModControl (std::string name, bool audio_rate=false, bool smooth_value=false, Output *internal_modulation=nullptr) |
Creates a base mod control, which is a control combined with a modulation input. | |
Output * | createMonoModControl (std::string name, bool audio_rate=false, bool smooth_value=false, Output *internal_modulation=nullptr) |
Creates a monophonic mod control, including applying parameter scaling. | |
Output * | createPolyModControl (std::string name, bool audio_rate=false, bool smooth_value=false, Output *internal_modulation=nullptr, Input *reset=nullptr) |
Creates a polyphonic mod control, including applying parameter scaling. | |
Output * | createTempoSyncSwitch (std::string name, Processor *frequency, const Output *beats_per_second, bool poly, Input *midi=nullptr) |
Creates a tempo sync switch that toggles between tempo-based frequency and free-running frequency. | |
void | createStatusOutput (std::string name, Output *source) |
Creates a status output associated with a given Output. | |
![]() | |
virtual void | addFeedback (Feedback *feedback) |
Adds a Feedback node to handle a feedback loop introduced by a connection. | |
virtual void | removeFeedback (Feedback *feedback) |
Removes a previously added Feedback node. | |
void | reorder (Processor *processor) |
Reorders the internal processing sequence to account for a Processor's dependencies. | |
virtual void | updateAllProcessors () |
Updates all processors to match the global order. Called when changes occur. | |
force_inline bool | shouldUpdate () |
Checks if local changes need to be synchronized with global changes. | |
virtual void | createAddedProcessors () |
Creates any processors that were added at the global level but not yet replicated locally. | |
virtual void | deleteRemovedProcessors () |
Deletes any processors that were removed at the global level but not yet removed locally. | |
const Processor * | getContext (const Processor *processor) const |
Gets the processor context within this router for a global Processor reference. | |
void | getDependencies (const Processor *processor) const |
Populates the internal dependencies structure for a given Processor. | |
Processor * | getLocalProcessor (const Processor *global_processor) |
Retrieves the local instance of a globally defined Processor. | |
![]() | |
Output * | addOutput (int oversample=1) |
Creates and registers a new Output. Handles control rate vs. audio rate. | |
Input * | addInput () |
Creates and registers a new Input, initially connected to null_source_. | |
![]() | |
std::shared_ptr< ModuleData > | data_ |
Shared data storage for this SynthModule. | |
![]() | |
std::shared_ptr< CircularQueue< Processor * > > | global_order_ |
Global processing order reference. | |
std::shared_ptr< CircularQueue< Processor * > > | global_reorder_ |
Temporary storage for reorder operations. | |
CircularQueue< Processor * > | local_order_ |
Local ordering of Processors. | |
std::map< const Processor *, std::pair< int, std::unique_ptr< Processor > > > | processors_ |
Map of global to local Processors. | |
std::map< const Processor *, std::unique_ptr< Processor > > | idle_processors_ |
Idle Processors that are not active in the graph. | |
std::shared_ptr< std::vector< const Feedback * > > | global_feedback_order_ |
Global order of Feedback nodes. | |
std::vector< Feedback * > | local_feedback_order_ |
Local copies of Feedback nodes. | |
std::map< const Processor *, std::pair< int, std::unique_ptr< Feedback > > > | feedback_processors_ |
Map of global to local Feedback processors. | |
std::shared_ptr< int > | global_changes_ |
Global change counter. | |
int | local_changes_ |
Local change counter to track synchronization with global changes. | |
std::shared_ptr< CircularQueue< const Processor * > > | dependencies_ |
Queue for dependencies calculations. | |
std::shared_ptr< CircularQueue< const Processor * > > | dependencies_visited_ |
Queue of visited processors for dependencies calc. | |
std::shared_ptr< CircularQueue< const Processor * > > | dependency_inputs_ |
Queue of processors to check inputs for dependencies. | |
![]() | |
std::shared_ptr< ProcessorState > | state_ |
Shared state (sample rate, oversample, etc.) | |
int | plugging_start_ |
The index at which plugNext starts searching for an unplugged input. | |
std::vector< std::shared_ptr< Input > > | owned_inputs_ |
Inputs owned by this Processor. | |
std::vector< std::shared_ptr< Output > > | owned_outputs_ |
Outputs owned by this Processor. | |
std::shared_ptr< std::vector< Input * > > | inputs_ |
All inputs, owned or external. | |
std::shared_ptr< std::vector< Output * > > | outputs_ |
All outputs, owned or external. | |
ProcessorRouter * | router_ |
The ProcessorRouter that manages this Processor. | |
![]() | |
static const Output | null_source_ |
A null (dummy) source used for unconnected inputs. | |
Core class responsible for handling note events, oversampling, and the main effects chain.
The main synthesis engine that handles voices, modulation, effects, and other top-level audio processing components for the Vital synthesizer.
The SoundEngine manages the top-level module architecture for Vital's effect and modulation engines, connecting note handling, oversampling, effect chaining, and modulation routing. It derives from SynthModule for the base module framework and NoteHandler for note-level logic.
The SoundEngine is responsible for managing voices, applying modulation, handling note on/off events, applying oversampling, and routing audio through the effects chain. It integrates with a SynthVoiceHandler to manage polyphony, and it uses a ReorderableEffectChain to process the final audio output.
vital::SoundEngine::SoundEngine | ( | ) |
Constructs a SoundEngine and initializes internal state and controls.
Default constructor for SoundEngine, initializes vital controls and reserves space for mod processors.
|
virtual |
Destroys the SoundEngine, cleaning up submodules and modulation resources.
Destructor. Prepares the modulation handler for deletion by removing processors.
vital::SoundEngine::SoundEngine | ( | ) |
Constructs a new SoundEngine instance.
|
virtual |
Destroys the SoundEngine instance.
|
overridevirtual |
Turns off all notes on all channels at the specified sample index.
Disables all notes across all channels at a given sample index.
sample | The sample index at which to stop notes. |
sample | The sample index to stop. |
Implements vital::NoteHandler.
|
overridevirtual |
Sends all voices a note-off command at a given sample.
sample | The sample index to apply the note-off command. |
Implements vital::NoteHandler.
|
overridevirtual |
Turns off all notes on a specific channel at a given sample.
Disables all notes on a specific channel at a given sample.
sample | The sample index to stop notes. |
channel | The MIDI channel. |
sample | The sample index. |
channel | The MIDI channel. |
Implements vital::NoteHandler.
|
overridevirtual |
Sends all voices on a given channel a note-off command.
sample | The sample index at which to apply the note-off command. |
channel | The channel from which to remove active notes. |
Implements vital::NoteHandler.
void vital::SoundEngine::allNotesOffRange | ( | int | sample, |
int | from_channel, | ||
int | to_channel ) |
Turns off all notes within a range of channels.
Disables all notes across a range of channels.
sample | The sample index at which to stop notes. |
from_channel | The first channel in the range. |
to_channel | The last channel in the range (inclusive). |
sample | The sample index. |
from_channel | The first channel in the range. |
to_channel | The last channel in the range (inclusive). |
void vital::SoundEngine::allNotesOffRange | ( | int | sample, |
int | from_channel, | ||
int | to_channel ) |
Sends all voices in a range of channels a note-off command.
sample | The sample index at which to apply the note-offs. |
from_channel | The first channel in the range. |
to_channel | The last channel in the range. |
|
overridevirtual |
Stops and resets all currently playing notes and any lingering states in the effect chain.
Clears the effect chain states, stopping sound or lingering effects.
Implements vital::NoteHandler.
|
overridevirtual |
Turns off all sounds immediately.
Implements vital::NoteHandler.
void vital::SoundEngine::checkOversampling | ( | ) |
Checks if the oversampling setting or sample rate has changed, and reconfigures if needed.
Checks if the oversampling setting or sample rate has changed and re-applies if needed.
void vital::SoundEngine::checkOversampling | ( | ) |
Checks if the oversampling settings have changed and updates accordingly.
void vital::SoundEngine::connectModulation | ( | const modulation_change & | change | ) |
Connects a modulation source to a destination via the given modulation_change structure.
Connects a modulation source to a destination using the provided modulation_change details.
change | A struct describing the source, destination, and scaling parameters. |
Sets control rate based on whether either the source or destination is audio-rate.
void vital::SoundEngine::connectModulation | ( | const modulation_change & | change | ) |
Connects a modulation source to its destination.
change | The modulation change descriptor. |
|
overridevirtual |
Synchronizes all time-based modules to a given time, e.g. for timeline-based automation.
Synchronizes time-based modules (effects chain, mod handler) to an absolute time.
seconds | The absolute time in seconds. |
seconds | Absolute time in seconds. |
Reimplemented from vital::SynthModule.
|
overridevirtual |
Corrects internal timing to a given absolute time in seconds.
seconds | The time in seconds to correct to. |
Reimplemented from vital::SynthModule.
void vital::SoundEngine::disableModSource | ( | const std::string & | source | ) |
Disables a specific named modulation source.
Disables a named modulation source, e.g. "env_2".
source | The name of the modulation source to disable. |
source | The name of the source. |
void vital::SoundEngine::disableModSource | ( | const std::string & | source | ) |
Disables a modulation source by name.
source | The name of the modulation source to disable. |
void vital::SoundEngine::disableUnnecessaryModSources | ( | ) |
Disables unnecessary modulation sources in the engine to save CPU.
Disables any unnecessary mod sources in the modulation handler for CPU efficiency.
void vital::SoundEngine::disableUnnecessaryModSources | ( | ) |
Disables any modulation sources that are not required.
void vital::SoundEngine::disconnectModulation | ( | const modulation_change & | change | ) |
Disconnects a previously established modulation route.
Removes a previously connected modulation, disabling the processor and resetting rate modes.
change | A struct describing the source, destination, and parameters for removal. |
void vital::SoundEngine::disconnectModulation | ( | const modulation_change & | change | ) |
Disconnects a previously connected modulation source from its destination.
change | The modulation change descriptor. |
void vital::SoundEngine::enableModSource | ( | const std::string & | source | ) |
Enables a specific named modulation source by making its owner active.
Enables a named modulation source by enabling its owner module.
source | The name of the modulation source. |
source | The name of the modulation source, e.g. "lfo_1". |
void vital::SoundEngine::enableModSource | ( | const std::string & | source | ) |
Enables a modulation source by name.
source | The name of the modulation source to enable. |
const StereoMemory * vital::SoundEngine::getEqualizerMemory | ( | ) |
Retrieves the internal equalizer memory (used for certain effect processing).
Retrieves the stereo memory used by an equalizer effect in the chain (if any).
const StereoMemory * vital::SoundEngine::getEqualizerMemory | ( | ) |
Gets a pointer to the stereo memory used by the equalizer.
mono_float vital::SoundEngine::getLastActiveNote | ( | ) | const |
Retrieves the most recently active note number.
Retrieves the last note that was active in the engine.
mono_float vital::SoundEngine::getLastActiveNote | ( | ) | const |
Gets the last active note played.
LineGenerator * vital::SoundEngine::getLfoSource | ( | int | index | ) |
Retrieves a pointer to the LFO source line generator for the given index.
Retrieves the LFO source line generator by index from the modulation handler.
index | The LFO source index. |
index | LFO index. |
LineGenerator * vital::SoundEngine::getLfoSource | ( | int | index | ) |
Gets a pointer to an LFO source by index.
index | The index of the LFO source. |
ModulationConnectionBank & vital::SoundEngine::getModulationBank | ( | ) |
Provides access to the internal ModulationConnectionBank for managing mod routes.
Provides access to the internal modulation bank for connecting sources and destinations.
ModulationConnectionBank & vital::SoundEngine::getModulationBank | ( | ) |
Gets the modulation connection bank for this engine.
int vital::SoundEngine::getNumActiveVoices | ( | ) |
Returns the number of active voices in the engine.
Retrieves the number of active voices managed by the modulation handler.
int vital::SoundEngine::getNumActiveVoices | ( | ) |
Gets the number of currently active voices.
int vital::SoundEngine::getNumPressedNotes | ( | ) |
Returns the number of currently pressed notes across all channels.
Returns the number of pressed notes from the modulation handler.
int vital::SoundEngine::getNumPressedNotes | ( | ) |
Gets the number of currently pressed notes.
|
inline |
Retrieves the current oversampling factor (e.g., 1, 2, 4).
|
inline |
Gets the current oversampling amount.
Sample * vital::SoundEngine::getSample | ( | ) |
Sample * vital::SoundEngine::getSample | ( | ) |
Wavetable * vital::SoundEngine::getWavetable | ( | int | index | ) |
Wavetable * vital::SoundEngine::getWavetable | ( | int | index | ) |
Gets a pointer to a wavetable by index.
index | The index of the wavetable. |
|
overridevirtual |
Initializes the engine by creating base controls and submodules (effects chain, etc.).
Initializes base controls, sets up the EffectsModulationHandler, effect chain, decimator, stereo handling, etc.
Reimplemented from vital::ProcessorRouter.
|
overridevirtual |
Initializes the SoundEngine, setting up controls, voices, and effects.
Called internally upon construction to set up default parameters and processing modules.
Reimplemented from vital::ProcessorRouter.
bool vital::SoundEngine::isModSourceEnabled | ( | const std::string & | source | ) |
Checks if a given named modulation source is currently enabled.
Checks if a named modulation source is currently enabled.
source | The name of the source to check. |
source | The name of the source to check. |
bool vital::SoundEngine::isModSourceEnabled | ( | const std::string & | source | ) |
Checks if a modulation source is enabled.
source | The name of the modulation source. |
|
overridevirtual |
Handles a note-off event, releasing the voice allocated to the note.
Handles note-off events, releasing the voice in the modulation handler.
note | MIDI note number. |
lift | Note-off velocity or lift value. |
sample | The sample index where this note-off occurs. |
channel | The MIDI channel. |
note | MIDI note number. |
lift | Note-off velocity. |
sample | Sample index for the event. |
channel | MIDI channel. |
Implements vital::NoteHandler.
|
overridevirtual |
Triggers a note-off event.
note | The MIDI note number. |
lift | The note release velocity or lift value. |
sample | The sample index at which the note-off occurs. |
channel | The channel on which the note is being released. |
Implements vital::NoteHandler.
|
overridevirtual |
Handles a note-on event, triggering the engine’s voice handling.
Handles note-on events, triggering voices in the modulation handler.
note | MIDI note number. |
velocity | Note-on velocity. |
sample | The sample index where this note-on occurs. |
channel | The MIDI channel. |
note | MIDI note number. |
velocity | Note-on velocity. |
sample | Sample index for the event. |
channel | MIDI channel. |
Implements vital::NoteHandler.
|
overridevirtual |
Triggers a note-on event.
note | The MIDI note number. |
velocity | The note velocity. |
sample | The sample index at which the note-on occurs. |
channel | The channel on which the note is triggered. |
Implements vital::NoteHandler.
|
overridevirtual |
Processes a block of samples through the voice handler and effects chain.
num_samples | The number of samples to process. |
Reimplemented from vital::ProcessorRouter.
|
overridevirtual |
Processes a block of samples using the current state of the SoundEngine.
Processes audio through the entire chain of the SoundEngine.
Renders any oversampling, effect chaining, and modulation updates.
audio_in | A buffer of poly_float audio data to be processed (unused in many contexts). |
num_samples | Number of samples in the buffer. |
audio_in | Buffer of samples (poly_float), though many effects do not use direct audio_in. |
num_samples | The block size to process. |
Reimplemented from vital::Processor.
void vital::SoundEngine::setAftertouch | ( | mono_float | note, |
mono_float | value, | ||
int | sample, | ||
int | channel ) |
Sets polyphonic aftertouch for a specific note on a given channel.
Sets polyphonic aftertouch for a specific note.
note | MIDI note number. |
value | Aftertouch value in [0..1]. |
sample | The sample index. |
channel | The MIDI channel. |
note | MIDI note number. |
value | Aftertouch in [0..1]. |
sample | Sample index. |
channel | MIDI channel. |
void vital::SoundEngine::setAftertouch | ( | mono_float | note, |
mono_float | value, | ||
int | sample, | ||
int | channel ) |
Sets note-based aftertouch values.
note | The MIDI note number. |
value | The aftertouch value. |
sample | The sample index at which this occurs. |
channel | The channel on which the aftertouch is applied. |
void vital::SoundEngine::setBpm | ( | mono_float | bpm | ) |
Updates the engine’s tempo in BPM, converting to beats per second for internal usage.
Updates the engine’s internal beats-per-minute, stored as beats_per_second.
bpm | The new tempo in beats per minute. |
bpm | The new BPM value. |
void vital::SoundEngine::setBpm | ( | mono_float | bpm | ) |
Sets the BPM (beats per minute) value for the engine.
bpm | The new BPM value. |
void vital::SoundEngine::setChannelAftertouch | ( | int | channel, |
mono_float | value, | ||
int | sample ) |
Sets channel-wide aftertouch on a given channel.
Sets channel-wide aftertouch for a single channel.
channel | The MIDI channel. |
value | Aftertouch value in [0..1]. |
sample | The sample index. |
channel | MIDI channel. |
value | Aftertouch in [0..1]. |
sample | Sample index. |
void vital::SoundEngine::setChannelAftertouch | ( | int | channel, |
mono_float | value, | ||
int | sample ) |
Sets aftertouch values for an entire channel.
channel | The channel to set aftertouch on. |
value | The aftertouch value. |
sample | The sample index at which this occurs. |
void vital::SoundEngine::setChannelRangeAftertouch | ( | int | from_channel, |
int | to_channel, | ||
mono_float | value, | ||
int | sample ) |
Applies aftertouch to all channels in a specified range.
Sets channel-wide aftertouch for all channels in [from_channel..to_channel].
from_channel | The first channel in the range. |
to_channel | The last channel in the range (inclusive). |
value | Aftertouch value in [0..1]. |
sample | The sample index. |
from_channel | The first channel in the range. |
to_channel | The last channel in the range (inclusive). |
value | Aftertouch in [0..1]. |
sample | Sample index. |
void vital::SoundEngine::setChannelRangeAftertouch | ( | int | from_channel, |
int | to_channel, | ||
mono_float | value, | ||
int | sample ) |
Sets aftertouch values for a range of channels.
from_channel | The first channel in the range. |
to_channel | The last channel in the range. |
value | The aftertouch value. |
sample | The sample index at which this occurs. |
void vital::SoundEngine::setChannelRangeSlide | ( | int | from_channel, |
int | to_channel, | ||
mono_float | value, | ||
int | sample ) |
Applies channel slide to all channels in a specified range.
Sets channel-wide slide for all channels in the specified range.
from_channel | The first channel in the range. |
to_channel | The last channel in the range (inclusive). |
value | The slide value in [0..1]. |
sample | The sample index. |
from_channel | The first channel in the range. |
to_channel | The last channel in the range. |
value | Slide in [0..1]. |
sample | Sample index. |
void vital::SoundEngine::setChannelRangeSlide | ( | int | from_channel, |
int | to_channel, | ||
mono_float | value, | ||
int | sample ) |
Sets slide values for a range of channels.
from_channel | The first channel in the range. |
to_channel | The last channel in the range. |
value | The slide value. |
sample | The sample index at which this occurs. |
void vital::SoundEngine::setChannelSlide | ( | int | channel, |
mono_float | value, | ||
int | sample ) |
Sets channel slide (e.g., an expression or glide parameter) on a specific channel.
Sets channel-wide slide on a single channel.
channel | The MIDI channel. |
value | The slide value in [0..1]. |
sample | The sample index. |
channel | MIDI channel. |
value | Slide in [0..1]. |
sample | Sample index. |
void vital::SoundEngine::setChannelSlide | ( | int | channel, |
mono_float | value, | ||
int | sample ) |
Sets channel-based slide (MPE/MIDI CC glides).
channel | The channel on which to set the slide value. |
value | The slide value. |
sample | The sample index at which this occurs. |
void vital::SoundEngine::setModWheel | ( | mono_float | value, |
int | channel ) |
Sets the mod wheel value for a given MIDI channel.
Sets the mod wheel value for a specific channel.
value | Mod wheel value in range [0..1]. |
channel | The MIDI channel. |
value | The mod wheel value [0..1]. |
channel | The MIDI channel. |
void vital::SoundEngine::setModWheel | ( | mono_float | value, |
int | channel ) |
Sets the modulation wheel value for a given channel.
value | The modulation wheel value. |
channel | The channel to set the mod wheel on. |
void vital::SoundEngine::setModWheelAllChannels | ( | mono_float | value | ) |
Sets the mod wheel value for all MIDI channels.
Sets the mod wheel value for all channels.
value | The mod wheel value in range [0..1]. |
value | The mod wheel value [0..1]. |
void vital::SoundEngine::setModWheelAllChannels | ( | mono_float | value | ) |
Sets the modulation wheel value for all channels.
value | The modulation wheel value. |
void vital::SoundEngine::setOversamplingAmount | ( | int | oversampling_amount, |
int | sample_rate ) |
Configures the engine’s oversampling factor and sample rate.
Configures oversampling for the engine, upsampler, modulation handler, and effect chain.
oversampling_amount | The new oversampling factor (e.g., 2, 4). |
sample_rate | The current audio sample rate in Hz. |
oversampling_amount | The integer oversampling factor. |
sample_rate | The current audio sample rate in Hz. |
void vital::SoundEngine::setPitchWheel | ( | mono_float | value, |
int | channel ) |
Sets the pitch wheel value for a specified MIDI channel.
Sets the pitch wheel value for a specific channel.
value | The pitch bend value in range [-1..1]. |
channel | The MIDI channel. |
value | The pitch bend amount in [-1..1]. |
channel | The MIDI channel. |
void vital::SoundEngine::setPitchWheel | ( | mono_float | value, |
int | channel ) |
Sets the pitch wheel value for a given channel.
value | The pitch wheel value. |
channel | The channel to set the pitch wheel on. |
void vital::SoundEngine::setTuning | ( | const Tuning * | tuning | ) |
void vital::SoundEngine::setTuning | ( | const Tuning * | tuning | ) |
Sets the tuning to use for pitch calculations.
tuning | A pointer to the Tuning object to apply. |
void vital::SoundEngine::setZonedPitchWheel | ( | mono_float | value, |
int | from_channel, | ||
int | to_channel ) |
Applies a pitch wheel value to a range of MIDI channels.
Sets a pitch wheel value for a range of channels.
value | The pitch bend value in range [-1..1]. |
from_channel | The first channel in the range. |
to_channel | The last channel in the range (inclusive). |
value | The pitch bend in [-1..1]. |
from_channel | The first channel in the range. |
to_channel | The last channel in the range (inclusive). |
void vital::SoundEngine::setZonedPitchWheel | ( | mono_float | value, |
int | from_channel, | ||
int | to_channel ) |
Sets the pitch wheel value for a range of channels.
value | The pitch wheel value. |
from_channel | The first channel in the range. |
to_channel | The last channel in the range. |
void vital::SoundEngine::sostenutoOff | ( | int | sample, |
int | channel ) |
Disengages sostenuto on a single MIDI channel.
Disengages sostenuto for a single channel.
sample | The sample index at which sostenuto is released. |
channel | The MIDI channel. |
sample | Sample index at which sostenuto is released. |
channel | MIDI channel. |
void vital::SoundEngine::sostenutoOff | ( | int | sample, |
int | channel ) |
Turns sostenuto off for a given channel at a specific sample.
sample | The sample index at which to turn sostenuto off. |
channel | The channel on which to turn sostenuto off. |
void vital::SoundEngine::sostenutoOffRange | ( | int | sample, |
int | from_channel, | ||
int | to_channel ) |
Disengages sostenuto on a range of MIDI channels.
Disengages sostenuto for all channels in the given range.
sample | The sample index at which sostenuto is released. |
from_channel | The first channel in the range. |
to_channel | The last channel in the range (inclusive). |
sample | Sample index at which sostenuto is released. |
from_channel | First channel in the range. |
to_channel | Last channel in the range (inclusive). |
void vital::SoundEngine::sostenutoOffRange | ( | int | sample, |
int | from_channel, | ||
int | to_channel ) |
Turns sostenuto off for a range of channels at a given sample.
sample | The sample index at which to turn sostenuto off. |
from_channel | The first channel in the range. |
to_channel | The last channel in the range. |
void vital::SoundEngine::sostenutoOn | ( | int | channel | ) |
Engages sostenuto on a single MIDI channel (holding only currently pressed notes).
Engages sostenuto on a single channel, holding only currently active notes.
channel | The MIDI channel to engage sostenuto. |
channel | MIDI channel. |
void vital::SoundEngine::sostenutoOn | ( | int | channel | ) |
Turns sostenuto on for a given channel.
channel | The channel to apply sostenuto. |
void vital::SoundEngine::sostenutoOnRange | ( | int | from_channel, |
int | to_channel ) |
Engages sostenuto on a range of MIDI channels.
Engages sostenuto for all channels in a specified range.
from_channel | The first channel in the range. |
to_channel | The last channel in the range (inclusive). |
from_channel | First channel in the range. |
to_channel | Last channel in the range (inclusive). |
void vital::SoundEngine::sostenutoOnRange | ( | int | from_channel, |
int | to_channel ) |
Turns sostenuto on for a range of channels.
from_channel | The first channel in the range. |
to_channel | The last channel in the range. |
void vital::SoundEngine::sustainOff | ( | int | sample, |
int | channel ) |
Disengages sustain on a single MIDI channel, releasing notes if their keys are up.
Turns sustain off for a given channel, releasing notes if keys are up.
sample | The sample index at which sustain is released. |
channel | The MIDI channel. |
sample | Sample index at which sustain is released. |
channel | MIDI channel. |
void vital::SoundEngine::sustainOff | ( | int | sample, |
int | channel ) |
Turns sustain off for a given channel at a specific sample.
sample | The sample index at which to turn sustain off. |
channel | The channel on which to turn sustain off. |
void vital::SoundEngine::sustainOffRange | ( | int | sample, |
int | from_channel, | ||
int | to_channel ) |
Disengages sustain on a range of MIDI channels.
Disengages sustain for all channels in the given range.
sample | The sample index at which sustain is released. |
from_channel | The first channel in the range. |
to_channel | The last channel in the range (inclusive). |
sample | Sample index at which sustain is released. |
from_channel | First channel in the range. |
to_channel | Last channel in the range (inclusive). |
void vital::SoundEngine::sustainOffRange | ( | int | sample, |
int | from_channel, | ||
int | to_channel ) |
Turns sustain off for a range of channels at a given sample.
sample | The sample index at which to turn sustain off. |
from_channel | The first channel in the range. |
to_channel | The last channel in the range. |
void vital::SoundEngine::sustainOn | ( | int | channel | ) |
Engages sustain on a single MIDI channel (holding all pressed notes).
Turns sustain on for a given MIDI channel, holding all pressed notes.
channel | The MIDI channel to sustain. |
channel | MIDI channel. |
void vital::SoundEngine::sustainOn | ( | int | channel | ) |
Turns sustain on for a given channel.
channel | The channel to sustain. |
void vital::SoundEngine::sustainOnRange | ( | int | from_channel, |
int | to_channel ) |
Engages sustain on a range of MIDI channels.
Engages sustain for all channels in a specified range.
from_channel | The first channel in the range. |
to_channel | The last channel in the range (inclusive). |
from_channel | First channel in the range. |
to_channel | Last channel in the range (inclusive). |
void vital::SoundEngine::sustainOnRange | ( | int | from_channel, |
int | to_channel ) |
Turns sustain on for a range of channels.
from_channel | The first channel in the range. |
to_channel | The last channel in the range. |
|
staticconstexpr |
Default oversampling factor.
The default oversampling amount for the engine.
|
staticconstexpr |
Default sample rate used before explicit configuration.
The default sample rate for the engine.