RNBO: RNBO::CoreObject Class Reference

Public Member Functions | |
CoreObject (EventHandler *handler=nullptr) | |
Construct a new CoreObject. More... | |
CoreObject (UniquePtr< PatcherInterface > patcher, EventHandler *handler=nullptr) | |
Construct a new CoreObject. More... | |
CoreObject (const CoreObject &other)=delete | |
CoreObject & | operator= (const CoreObject &other)=delete |
CoreObject (CoreObject &&other)=default | |
CoreObject & | operator= (CoreObject &&other)=default |
ParameterIndex | getNumParameters () const override |
Get the number of visible parameters. More... | |
ConstCharPointer | getParameterName (ParameterIndex index) const override |
Get the parameter name (may not be unique) More... | |
ConstCharPointer | getParameterId (ParameterIndex index) const override |
Get the unique ID of a parameter. More... | |
void | getParameterInfo (ParameterIndex index, ParameterInfo *info) const override |
Get detailed information about a parameter. More... | |
ParameterValue | getParameterValue (ParameterIndex index) override |
void | setParameterValue (ParameterIndex index, ParameterValue value, MillisecondTime time=RNBOTimeNow) override |
Set a parameter's value. More... | |
void | setParameterValueNormalized (ParameterIndex index, ParameterValue normalizedValue, MillisecondTime time=RNBOTimeNow) override |
Set a parameter's normalized [0..1] value. More... | |
ParameterValue | convertToNormalizedParameterValue (ParameterIndex index, ParameterValue value) const override |
Convert a parameter value from its real value to a normalized representation [0..1]. More... | |
ParameterValue | convertFromNormalizedParameterValue (ParameterIndex index, ParameterValue normalizedValue) const override |
Convert a parameter value from a normalized representation [0..1] to its real value. More... | |
ParameterValue | constrainParameterValue (ParameterIndex index, ParameterValue value) const override |
Apply and get the constrained parameter value. More... | |
ParameterEventInterfaceUniquePtr | createParameterInterface (ParameterEventInterface::Type type, EventHandler *handler) |
Create a lightweight interface for sending and receiving parameter values. More... | |
void | scheduleEvent (EventVariant event) |
Schedule an event. More... | |
void | sendMessage (MessageTag tag, number payload, MessageTag objectId=0, MillisecondTime eventTime=RNBOTimeNow) |
Send a number to named patcher inports. More... | |
void | sendMessage (MessageTag tag, UniqueListPtr payload, MessageTag objectId=0, MillisecondTime eventTime=RNBOTimeNow) |
Send a list message to named patcher inports. More... | |
void | sendMessage (MessageTag tag, MessageTag objectId=0, MillisecondTime eventTime=RNBOTimeNow) |
Send a bang to named patcher inports. More... | |
MessageTagInfo | resolveTag (MessageTag tag) const |
Look up the name associated with a MessageTag. More... | |
MessageIndex | getNumMessages () const |
const MessageInfo & | getMessageInfo (MessageIndex index) const |
Get information about a named inport or outport. More... | |
Index | getNumMidiInputPorts () const override |
Index | getNumMidiOutputPorts () const override |
ExternalDataIndex | getNumExternalDataRefs () const |
Get the number of external memory references. More... | |
ExternalDataId | getExternalDataId (ExternalDataIndex index) const |
Get the name of an external data reference. More... | |
const ExternalDataInfo | getExternalDataInfo (ExternalDataIndex index) const |
Get more information about an external data reference (like file type and filename) More... | |
void | setExternalData (ExternalDataId memoryId, char *data, size_t sizeInBytes, DataType type, ReleaseCallback callback=nullptr) |
Set the contents of an external data reference (thread-safe) More... | |
void | releaseExternalData (ExternalDataId memoryId) |
Release a block of memory (thread-safe) More... | |
void | setExternalDataHandler (ExternalDataHandler *handler) |
Set handlers for an external data reference which will be called before and after processing. More... | |
number | getSampleRate () const |
Index | getSamplesPerBlock () const |
bool | prepareToProcess (number sampleRate, Index maxBlockSize, bool force=false) |
Set the sample rate and vector size before doing any processing. More... | |
MillisecondTime | getCurrentTime () |
Get the current time (in ms) More... | |
void | setCurrentTime (MillisecondTime time) |
Set the current time (in ms) More... | |
void | process (const SampleValue *const *audioInputs, Index numInputs, SampleValue *const *audioOutputs, Index numOutputs, Index sampleFrames, const MidiEventList *midiInput=nullptr, MidiEventList *midiOutput=nullptr) |
Process non-interleaved SampleValue* audio buffers with optional MIDI I/O. More... | |
template<typename I , typename O > | |
void | process (I audioInputs, Index numInputs, O audioOutputs, Index numOutputs, Index sampleFrames, const MidiEventList *midiInput=nullptr, MidiEventList *midiOutput=nullptr) |
Convert and process a generic audio buffer with optional MIDI I/O. More... | |
Index | getNumInputChannels () const override |
Index | getNumOutputChannels () const override |
ParameterIndex | getNumSignalInParameters () const |
Get the number of signal input parameters. More... | |
ParameterIndex | getNumSignalOutParameters () const |
Get the number of signal output parameters. More... | |
bool | setPatcher () |
Set or replace the engine's patcher with a default patcher. More... | |
bool | setPatcher (UniquePtr< PatcherInterface > patcher) |
Replace the engine's patcher with a new instance. More... | |
void | setPreset (UniquePresetPtr preset) |
Schedule a preset change. More... | |
void | setPresetSync (UniquePresetPtr preset) |
Set a preset immediately. More... | |
void | getPreset (PresetCallback callback) |
Get a preset (asynchronous) More... | |
ConstPresetPtr | getPresetSync () |
Get a preset (synchronous) More... | |
void | setPatcherChangedHandler (PatcherChangedHandler *handler) |
Set the handler for patcher change notifications. More... | |
ParameterIndex | getParameterIndexForID (ConstCharPointer paramid) const |
Get the parameter index from a parameter ID. More... | |
Index | getProbingChannels (MessageTag outletId) const override |
Get the number of probing channels associated with an outlet. More... | |
![]() | |
virtual void | initialize () |
![]() | |
virtual ParameterValue | getParameterNormalized (ParameterIndex index) |
Get a parameter's normalized [0..1] value. More... | |
Protected Member Functions | |
void | initializeEngine (EventHandler *handler) |
Protected Attributes | |
UniquePtr< Engine > | _engine |
Constructor & Destructor Documentation
◆ CoreObject() [1/2]
RNBO::CoreObject::CoreObject | ( | EventHandler * | handler = nullptr | ) |
Construct a new CoreObject.
The CoreObject is the main API for using exported C++ code in external projects. It holds all state and data necessary for using RNBO.
- Parameters
-
handler an EventHandler for events generated by the CoreObject
◆ CoreObject() [2/2]
RNBO::CoreObject::CoreObject | ( | UniquePtr< PatcherInterface > | patcher, |
EventHandler * | handler = nullptr |
||
) |
Construct a new CoreObject.
The CoreObject is the main API for using exported C++ code in external projects. It holds all state and data necessary for using RNBO.
- Parameters
-
patcher a PatcherInterface to associate with the CoreObject handler an EventHandler for events generated by the CoreObject
Member Function Documentation
◆ constrainParameterValue()
|
overridevirtual |
Apply and get the constrained parameter value.
Parameter constraints include a minimum/maximum value and step constraints
- Parameters
-
index the parameter index value an unconstrained parameter value
- Returns
- the constrained parameter value
Reimplemented from RNBO::ParameterInterface.
◆ convertFromNormalizedParameterValue()
|
overridevirtual |
Convert a parameter value from a normalized representation [0..1] to its real value.
- Parameters
-
index the parameter index normalizedValue the normalized value
- Returns
- the real value of the parameter
Implements RNBO::ParameterInterface.
◆ convertToNormalizedParameterValue()
|
overridevirtual |
Convert a parameter value from its real value to a normalized representation [0..1].
- Parameters
-
index the parameter index value the real value of the parameter
- Returns
- a normalized ParameterValue
Implements RNBO::ParameterInterface.
◆ createParameterInterface()
ParameterEventInterfaceUniquePtr RNBO::CoreObject::createParameterInterface | ( | ParameterEventInterface::Type | type, |
EventHandler * | handler | ||
) |
Create a lightweight interface for sending and receiving parameter values.
The CoreObject, by default, holds a parameter interface for sending and receiving events with the thread-safe MultiProducer interface type.
- See also
- RNBO::ParameterEventInterface
- Parameters
-
type the type of parameter event interface to create handler an event handler
- Returns
- a ParameterEventInterfaceUniquePtr
NOTE: if you create a thread safe async parameter interface you will NOT get any events and values out unless you use a handler which correctly drains these events
◆ getCurrentTime()
MillisecondTime RNBO::CoreObject::getCurrentTime | ( | ) |
Get the current time (in ms)
This method is only accurate when called from the audio/processing thread
- Returns
- the current time in milliseconds
◆ getExternalDataId()
ExternalDataId RNBO::CoreObject::getExternalDataId | ( | ExternalDataIndex | index | ) | const |
Get the name of an external data reference.
- See also
- RNBO::ExternalDataRef
- Parameters
-
index the external data reference index
- Returns
- a C-style string containing the name of the external data
◆ getExternalDataInfo()
const ExternalDataInfo RNBO::CoreObject::getExternalDataInfo | ( | ExternalDataIndex | index | ) | const |
Get more information about an external data reference (like file type and filename)
- See also
- RNBO::ExternalDataRef
- Parameters
-
index the index of the external data
- Returns
- a struct containing information about the external data
◆ getMessageInfo()
const MessageInfo& RNBO::CoreObject::getMessageInfo | ( | MessageIndex | index | ) | const |
Get information about a named inport or outport.
- Parameters
-
index the MessageIndex
- Returns
- a reference to the MessageInfo
◆ getNumExternalDataRefs()
ExternalDataIndex RNBO::CoreObject::getNumExternalDataRefs | ( | ) | const |
Get the number of external memory references.
- See also
- RNBO::ExternalDataRef
- Returns
- the number of external data references
◆ getNumInputChannels()
|
overridevirtual |
- Returns
- the number of audio input channels processed by the current patcher
Implements RNBO::BaseInterface.
◆ getNumMessages()
MessageIndex RNBO::CoreObject::getNumMessages | ( | ) | const |
- Returns
- the count of named inports and outports
◆ getNumMidiInputPorts()
|
overridevirtual |
- Returns
- the number of MIDI inputs
Implements RNBO::BaseInterface.
◆ getNumMidiOutputPorts()
|
overridevirtual |
- Returns
- the number of MIDI outputs
Implements RNBO::BaseInterface.
◆ getNumOutputChannels()
|
overridevirtual |
- Returns
- the number of audio output channels processed by the current patcher
Implements RNBO::BaseInterface.
◆ getNumParameters()
|
overridevirtual |
Get the number of visible parameters.
Note that not all parameters are visible (for example, params in gen~ are not automatically exposed as RNBO parameters). The count of visible parameters is usually the same as the number of param/param~ objects in a RNBO~ patch.
- Returns
- the number of visible parameters
Implements RNBO::ParameterInterface.
◆ getNumSignalInParameters()
ParameterIndex RNBO::CoreObject::getNumSignalInParameters | ( | ) | const |
Get the number of signal input parameters.
Signal input parameters can be handed into the processing function as additional audio inputs.
- Returns
- the number of signal input parameters
◆ getNumSignalOutParameters()
ParameterIndex RNBO::CoreObject::getNumSignalOutParameters | ( | ) | const |
Get the number of signal output parameters.
Signal input parameters will be handed out of the processing function as additional audio outputs.
- Returns
- the number of signal output parameters
◆ getParameterId()
|
overridevirtual |
Get the unique ID of a parameter.
The unique ID of a parameter can be the same as the parameter ID. If a parameter is nested in a subpatcher, a prefix is added to the parameter name in order to disambiguate. Examples of parameter IDs:
- "my_toplevel_param"
- "p_obj-2/my_nested_param"
- "poly/p_obj-18/my_nested_poly_param"
- Parameters
-
index the parameter index
- Returns
- a C-style string containing the parameter ID
Implements RNBO::ParameterInterface.
◆ getParameterIndexForID()
ParameterIndex RNBO::CoreObject::getParameterIndexForID | ( | ConstCharPointer | paramid | ) | const |
Get the parameter index from a parameter ID.
- Parameters
-
paramid the parameter ID
- Returns
- the parameter index
◆ getParameterInfo()
|
overridevirtual |
Get detailed information about a parameter.
- Parameters
-
index the parameter index info a pointer to a ParameterInfo object to fill
Implements RNBO::ParameterInterface.
◆ getParameterName()
|
overridevirtual |
Get the parameter name (may not be unique)
- Parameters
-
index the parameter index
- Returns
- a C-style string containing the parameter name
Implements RNBO::ParameterInterface.
◆ getParameterValue()
|
overridevirtual |
- Parameters
-
index the parameter index
- Returns
- the value of the parameter
Implements RNBO::ParameterInterface.
◆ getPreset()
void RNBO::CoreObject::getPreset | ( | PresetCallback | callback | ) |
Get a preset (asynchronous)
The callback is called in the audio thread, so it is inadvisable to do any potentially blocking operations like opening files or allocating/freeing memory.
- Parameters
-
callback a PresetCallback to execute when the preset is available
◆ getPresetSync()
ConstPresetPtr RNBO::CoreObject::getPresetSync | ( | ) |
Get a preset (synchronous)
Pause event and audio processing to get a preset immediately.
- Returns
- the preset
◆ getProbingChannels()
|
override |
Get the number of probing channels associated with an outlet.
Call with outletId = 0 or TAG("") to get the maximum possible number of probing channels
- Parameters
-
outletId the ID of the outlet
- Returns
- the number of probing channels
◆ getSampleRate()
number RNBO::CoreObject::getSampleRate | ( | ) | const |
- Returns
- the current sample rate
◆ getSamplesPerBlock()
Index RNBO::CoreObject::getSamplesPerBlock | ( | ) | const |
- Returns
- the current vector size
◆ prepareToProcess()
bool RNBO::CoreObject::prepareToProcess | ( | number | sampleRate, |
Index | maxBlockSize, | ||
bool | force = false |
||
) |
Set the sample rate and vector size before doing any processing.
This method is almost a no-op when there is no change in sample rate or vector size and force is false (the default) so it is suitable to call before each processing call. Note that an increase of maxBlockSize will allocate memory, however.
If this method returns false, do not call process() afterwards. Instead, call prepareToProcess() again.
- Parameters
-
sampleRate the sample rate to use maxBlockSize the maximum vector size; actual processing could be made in smaller chunks force if true, ensures the dspsetup methods of patcher objects are called
- Returns
- false if called during setPatcher, true otherwise
◆ process() [1/2]
void RNBO::CoreObject::process | ( | const SampleValue *const * | audioInputs, |
Index | numInputs, | ||
SampleValue *const * | audioOutputs, | ||
Index | numOutputs, | ||
Index | sampleFrames, | ||
const MidiEventList * | midiInput = nullptr , |
||
MidiEventList * | midiOutput = nullptr |
||
) |
Process non-interleaved SampleValue* audio buffers with optional MIDI I/O.
- Parameters
-
audioInputs non-interleaved audio inputs (e.g. a 2D array: SampleValues[numInputs][sampleFrames]) numInputs the number of audio input buffers audioOutputs non-interleaved audio outputs (e.g. a 2D array: SampleValues[numOutputs][sampleFrames]) numOutputs the number of audio output buffers sampleFrames the number of samples in a single input or output midiInput an optional pointer to a MidiEventList of input events associated with this audio vector midiOutput an optional pointer to a MidiEventList which can receive MIDI output generated during the audio vector
◆ process() [2/2]
|
inline |
Convert and process a generic audio buffer with optional MIDI I/O.
In situations where non-interleaved SampleValue* audio buffers are not available (e.g. the audio buffers are not sizeof(SampleValue) or the buffers are interleaved), use this method to convert and process the audio buffers.
- Template Parameters
-
I the type of input audio buffer O the type of output audio buffer
- Parameters
-
audioInputs audio input buffers numInputs the number of audio input buffers audioOutputs audio output buffers numOutputs the number of audio output buffers sampleFrames the number of samples in a single input or output midiInput an optional pointer to a MidiEventList of input events associated with this audio vector midiOutput an optional pointer to a
◆ releaseExternalData()
void RNBO::CoreObject::releaseExternalData | ( | ExternalDataId | memoryId | ) |
Release a block of memory (thread-safe)
Call releaseExternalData() on an external data reference to tell RNBO to stop using a block of memory in a thread-safe way. If a ReleaseCallback is associated with the data reference, it will be called when the data is no longer in use.
- Parameters
-
memoryId the name of the data reference
◆ resolveTag()
MessageTagInfo RNBO::CoreObject::resolveTag | ( | MessageTag | tag | ) | const |
Look up the name associated with a MessageTag.
- Parameters
-
tag a MessageTag
- Returns
- the name associated with the tag as a C-style string
◆ scheduleEvent()
void RNBO::CoreObject::scheduleEvent | ( | EventVariant | event | ) |
Schedule an event.
There are a number of event variants that can be scheduled (like MIDI events, tempo events, and parameter events). For all of the variants available, see the related documentation.
- See also
- RNBO::EventVariant
- Parameters
-
event an event to schedule
◆ sendMessage() [1/3]
void RNBO::CoreObject::sendMessage | ( | MessageTag | tag, |
MessageTag | objectId = 0 , |
||
MillisecondTime | eventTime = RNBOTimeNow |
||
) |
Send a bang to named patcher inports.
- Parameters
-
tag the inport name MessageTag created from a char* or const char* via the TAG() function objectId optionally specify a receiving object (mostly used internally) eventTime time the message should be scheduled for (use RNBOTimeNow or 0 for "as soon as possible")
For example:
◆ sendMessage() [2/3]
void RNBO::CoreObject::sendMessage | ( | MessageTag | tag, |
number | payload, | ||
MessageTag | objectId = 0 , |
||
MillisecondTime | eventTime = RNBOTimeNow |
||
) |
Send a number to named patcher inports.
- Parameters
-
tag the inport name MessageTag created from a char* or const char* via the TAG() function payload a number objectId optionally specify a receiving object (mostly used internally) eventTime time the message should be scheduled for (use RNBOTimeNow or 0 for "as soon as possible")
For example:
◆ sendMessage() [3/3]
void RNBO::CoreObject::sendMessage | ( | MessageTag | tag, |
UniqueListPtr | payload, | ||
MessageTag | objectId = 0 , |
||
MillisecondTime | eventTime = RNBOTimeNow |
||
) |
Send a list message to named patcher inports.
- Parameters
-
tag the inport name MessageTag created from a char* or const char* via the TAG() function payload a UniqueListPtr of numbers objectId optionally specify a receiving object (mostly used internally) eventTime time the message should be scheduled for (use RNBOTimeNow or 0 for "as soon as possible")
For example:
◆ setCurrentTime()
void RNBO::CoreObject::setCurrentTime | ( | MillisecondTime | time | ) |
Set the current time (in ms)
This can be used to tightly sync RNBO and host time. Jumping, rather than forwarding time according to the processed samples, may result in unpredictable results.
Do not call this method outside of the audio/processing thread.
- Parameters
-
time the new time in milliseconds
◆ setExternalData()
void RNBO::CoreObject::setExternalData | ( | ExternalDataId | memoryId, |
char * | data, | ||
size_t | sizeInBytes, | ||
DataType | type, | ||
ReleaseCallback | callback = nullptr |
||
) |
Set the contents of an external data reference (thread-safe)
Note: From the moment setExternalData() is called, memory can and will be used at any given time by RNBO, so do not reallocate or change the size unless the memory has been released via releaseExternalData().
- Parameters
-
memoryId the name of the data reference data byte array of data sizeInBytes size of the data array in bytes type buffer type: callback synchronous callback to be called when the engine releases the memory after releaseExternalData()
◆ setExternalDataHandler()
void RNBO::CoreObject::setExternalDataHandler | ( | ExternalDataHandler * | handler | ) |
Set handlers for an external data reference which will be called before and after processing.
Some clients need to lock and unlock the memory at the beginning and end of processing, and this can be done by creating an ExternalDataHandler and implementing its processBeginCallback() and processEndCallback() methods. These will be called synchronously in the audio thread before and after processing, respectively.
- See also
- RNBO::ExternalDataHandler
- Parameters
-
handler the ExternalDataHandler to associate with the data reference
◆ setParameterValue()
|
overridevirtual |
Set a parameter's value.
- Parameters
-
index the parameter index value parameter value to set time when the parameter change should happen (default is RNBOTimeNow)
Implements RNBO::ParameterInterface.
◆ setParameterValueNormalized()
|
overridevirtual |
Set a parameter's normalized [0..1] value.
- Parameters
-
index the parameter index normalizedValue parameter normalized value to set time when the parameter change should happen (default is RNBOTimeNow)
Reimplemented from RNBO::ParameterInterface.
◆ setPatcher() [1/2]
bool RNBO::CoreObject::setPatcher | ( | ) |
Set or replace the engine's patcher with a default patcher.
Note: this blocks audio and event processing.
- Returns
- true on success, false on failure
◆ setPatcher() [2/2]
bool RNBO::CoreObject::setPatcher | ( | UniquePtr< PatcherInterface > | patcher | ) |
Replace the engine's patcher with a new instance.
Note: this blocks audio and event processing.
- Parameters
-
patcher the new patcher instance
- Returns
- true on success, false on failure
◆ setPatcherChangedHandler()
void RNBO::CoreObject::setPatcherChangedHandler | ( | PatcherChangedHandler * | handler | ) |
Set the handler for patcher change notifications.
The handler is called synchronously at the end of the setPatcher call and before any audio processing happens. As such, be aware of taking too much time in the handler.
- Parameters
-
handler a pointer to a PatcherChangedHandler
◆ setPreset()
void RNBO::CoreObject::setPreset | ( | UniquePresetPtr | preset | ) |
Schedule a preset change.
- Parameters
-
preset the new preset
◆ setPresetSync()
void RNBO::CoreObject::setPresetSync | ( | UniquePresetPtr | preset | ) |
Set a preset immediately.
Note: this blocks audio and event processing.
- Parameters
-
preset the new preset
The documentation for this class was generated from the following file: