Allolib
1.0
C++ Components For Interactive Multimedia
|
The SynthVoice class. More...
Public Member Functions | |
bool | active () |
Returns true if voice is currently active. | |
virtual bool | setTriggerParams (float *pFields, int numFields=-1) |
virtual bool | setTriggerParams (std::vector< float > &pFields, bool noCalls=false) |
Set trigger parameter values. More... | |
virtual bool | setTriggerParams (std::vector< ParameterField > pFields, bool noCalls=false) |
Set parameter values. More... | |
virtual int | getTriggerParams (float *pFields, int maxParams=-1) |
Get this instance's parameter fields. More... | |
virtual std::vector< ParameterField > | getTriggerParams () |
Get this instance's parameter fields. More... | |
virtual void | onProcess (AudioIOData &) |
Override this function to define audio processing. More... | |
virtual void | onProcess (Graphics &) |
Override this function to define graphics for this synth. | |
virtual void | update (double dt=0) |
Override this function to update internal state, e.g. from an asynchronous simulator. More... | |
virtual void | init () |
Override this function to initialize internal data. More... | |
virtual void | onTriggerOn () |
Override this function to determine what needs to be done when note/event starts. More... | |
virtual void | onTriggerOff () |
determine what needs to be done when note/event ends Define this function to determine what needs to be done when note/event ends. e.g. trigger release in envelopes, etc. | |
virtual void | onFree () |
This function gets called after the voice is taken out of the processing chain. More... | |
void | triggerOn (int offsetFrames=0) |
Trigger a note by calling onTriggerOn() and setting voice as active. More... | |
void | triggerOff (int offsetFrames=0) |
Call the voice's onTriggerOff() function to begin note's deactivation. More... | |
void | id (int idValue) |
Set the id for this voice. More... | |
int | id () |
Get the id for this voice. More... | |
int | getStartOffsetFrames (unsigned int framesPerBuffer) |
returns the offset frames framesPerSecondand sets them to 0. More... | |
int | getEndOffsetFrames (unsigned int framesPerBuffer) |
void | userData (void *ud) |
void * | userData () |
unsigned int | numOutChannels () |
Query the number of channels this voice generates. More... | |
std::shared_ptr< Parameter > | createInternalTriggerParameter (std::string name, float defaultValue=0.0, float minValue=-9999.0, float maxValue=9999.0) |
A convenience function for quick creation of a managed parameter. More... | |
Parameter & | getInternalParameter (std::string name) |
Get reference to internal Parameter. More... | |
float | getInternalParameterValue (std::string name) |
Get value for internal trigger parameter. More... | |
void | setInternalParameterValue (std::string name, float value) |
Set value for internal trigger parameter. | |
virtual SynthVoice & | registerTriggerParameter (ParameterMeta ¶m) |
Register a parameter as a "trigger" parameter. More... | |
template<class... Args> | |
SynthVoice & | registerTriggerParameters (Args &... paramsArgs) |
SynthVoice & | operator<< (ParameterMeta ¶m) |
std::vector< ParameterMeta * > | triggerParameters () |
virtual SynthVoice & | registerParameter (ParameterMeta ¶m) |
registerParameter More... | |
template<class... Args> | |
SynthVoice & | registerParameters (Args &... paramsArgs) |
std::vector< ParameterMeta * > | parameters () |
Get the Voice's continuous (i.e. not "trigger") parameters. More... | |
void | free () |
Mark this voice as done. More... | |
Public Attributes | |
SynthVoice * | next {nullptr} |
Protected Member Functions | |
void | setNumOutChannels (unsigned int numOutputs) |
Set the number of outputs this SynthVoice generates. More... | |
Protected Attributes | |
std::vector< ParameterMeta * > | mTriggerParams |
std::vector< ParameterMeta * > | mContinuousParameters |
std::vector< std::shared_ptr< Parameter > > | mInternalParameters |
Friends | |
class | PolySynth |
The SynthVoice class.
To create new voices for a PolySynth, inherit from this class and override the onProcess() functions. When inheriting this class you must provide a default construct that takes no arguments.
Definition at line 72 of file al_PolySynth.hpp.
std::shared_ptr<Parameter> al::SynthVoice::createInternalTriggerParameter | ( | std::string | name, |
float | defaultValue = 0.0 , |
||
float | minValue = -9999.0 , |
||
float | maxValue = 9999.0 |
||
) |
A convenience function for quick creation of a managed parameter.
This creates a float type Parameter. The parameters instantiated through this function can be queried and set quickly through getInternalParameter(), getInternalParameterValue() and setInternalParameterValue(). These functions provide a quick way to add trigger parameters to the synth. These parameters are registered automatically, so they will be used in automatic GUIs and with the SynthSequencer.
|
inline |
Mark this voice as done.
This should be set within one of the render() functions when envelope or time is done and no more processing for the note is needed. The voice will be considered ready for retriggering by PolySynth.
It can also be used to force removal of a voice from the rendering chain without going through the release phase.
Definition at line 397 of file al_PolySynth.hpp.
Parameter& al::SynthVoice::getInternalParameter | ( | std::string | name | ) |
Get reference to internal Parameter.
name | parameter name |
Internal parameters are those registered through createInternalTriggerParameter()
float al::SynthVoice::getInternalParameterValue | ( | std::string | name | ) |
Get value for internal trigger parameter.
name | name of the parameter |
int al::SynthVoice::getStartOffsetFrames | ( | unsigned int | framesPerBuffer | ) |
returns the offset frames framesPerSecondand sets them to 0.
framesPerBuffer | number of frames per buffer |
Get the number of frames by which the start of this voice should be offset within a processing block. This value is decremented by framesPerBuffer once read.
|
virtual |
Get this instance's parameter fields.
The default behavior is to copy the values from the internal parameters that have been registered using registerParameterAsField or the << operator. Override this function in your voice if you need a different behavior.
Reimplemented in al::PositionedVoice.
|
inline |
|
inline |
|
inlinevirtual |
Override this function to initialize internal data.
This function should be called only once upon voice creation.
Definition at line 193 of file al_PolySynth.hpp.
|
inline |
Query the number of channels this voice generates.
Definition at line 274 of file al_PolySynth.hpp.
|
inlinevirtual |
This function gets called after the voice is taken out of the processing chain.
It can be used to store final states of a voice for example. This function is currently called in the time master domain, so it might be important to not do any blocking operations here.
Definition at line 219 of file al_PolySynth.hpp.
|
inlinevirtual |
Override this function to define audio processing.
io | You will need to mark this instance as done by calling the free() function when envelopes or processing is done. You should call free() from one of the render() functions. |
Definition at line 173 of file al_PolySynth.hpp.
|
inlinevirtual |
Override this function to determine what needs to be done when note/event starts.
When a note starts, internal data within the algorithm usually needs to be reset, e.g. reset envelopes, oscillator phase, etc.
Definition at line 202 of file al_PolySynth.hpp.
|
inline |
Get the Voice's continuous (i.e. not "trigger") parameters.
Definition at line 384 of file al_PolySynth.hpp.
|
inlinevirtual |
registerParameter
param |
Parameters are values that are meant to be updated while the voice is running, as opposed to "trigger" parameters that are set at onTrigger(). "Trigger" parameters will be stored in sequence text files, while regular parameters are meant to be changing within the voice. In distributed scenes, to synchronize the internal values within voices, the parameters must be registered through this function.
Definition at line 363 of file al_PolySynth.hpp.
|
inline |
Allows registering any number of parameters on a single line
Definition at line 372 of file al_PolySynth.hpp.
|
inlinevirtual |
Register a parameter as a "trigger" parameter.
param |
Trigger parameters are parameters meant to be set prior to triggering the note and inserting it in the rendering chain. Trigger parameters are garanteed to be set synchronously right before the note starts. Additionally they are stored as values in a text file for the event sequencer and are sent as part of the /triggerOn message when running distributed.
Definition at line 328 of file al_PolySynth.hpp.
|
inline |
Allows registering any number of trigger parameters on a single line
Definition at line 337 of file al_PolySynth.hpp.
|
inlineprotected |
Set the number of outputs this SynthVoice generates.
numOutputs | If you are using this voice within PolySynth, make sure this number is less or equal than the number of output channels opened for the audio device. If using in DynamicScene, make sure |
Definition at line 410 of file al_PolySynth.hpp.
|
inlinevirtual |
@brief Set parameter values @param pFields array containing the values @param numFields number of fields to process @return true if able to set the fields Note that this function allways triggers any associated callbacks, unlike
the other
Reimplemented in al::PositionedVoice.
Definition at line 93 of file al_PolySynth.hpp.
|
inlinevirtual |
Set trigger parameter values.
pFields | std::vector<float> containing the values |
Trigger parameters are parameters meant to be set at triggering, but that then stay constant throughout the duration of the instance.
Reimplemented in al::PositionedVoice.
Definition at line 112 of file al_PolySynth.hpp.
|
virtual |
Set parameter values.
pFields | std::vector<float> containing the values |
Reimplemented in al::PositionedVoice.
void al::SynthVoice::triggerOff | ( | int | offsetFrames = 0 | ) |
Call the voice's onTriggerOff() function to begin note's deactivation.
offsetFrames | This function can be called to programatically trigger the release of a voice |
void al::SynthVoice::triggerOn | ( | int | offsetFrames = 0 | ) |
Trigger a note by calling onTriggerOn() and setting voice as active.
offsetFrames | This function can be called to programatically trigger a voice. It is used for example in PolySynth to trigger a voice. |
|
inlinevirtual |
Override this function to update internal state, e.g. from an asynchronous simulator.
dt is the delta time elapsed since last update
Definition at line 186 of file al_PolySynth.hpp.