VCV Rack API v2
|
DSP processor instance for your module. More...
#include <Module.hpp>
Classes | |
struct | AddEvent |
struct | BypassEvent |
struct | BypassRoute |
struct | Expander |
Represents a message-passing channel for an adjacent module. More... | |
struct | ExpanderChangeEvent |
struct | PortChangeEvent |
struct | ProcessArgs |
struct | RandomizeEvent |
struct | RemoveEvent |
struct | ResetEvent |
struct | SampleRateChangeEvent |
struct | SaveEvent |
struct | SetMasterEvent |
struct | UnBypassEvent |
struct | UnsetMasterEvent |
Public Member Functions | |
Module () | |
Constructs a Module with no params, inputs, outputs, and lights. | |
DEPRECATED | Module (int numParams, int numInputs, int numOutputs, int numLights=0) |
Use config() instead. | |
virtual | ~Module () |
void | config (int numParams, int numInputs, int numOutputs, int numLights=0) |
Configures the number of Params, Outputs, Inputs, and Lights. | |
template<class TParamQuantity = ParamQuantity> | |
TParamQuantity * | configParam (int paramId, float minValue, float maxValue, float defaultValue, std::string name="", std::string unit="", float displayBase=0.f, float displayMultiplier=1.f, float displayOffset=0.f) |
Helper for creating a ParamQuantity and setting its properties. | |
template<class TSwitchQuantity = SwitchQuantity> | |
TSwitchQuantity * | configSwitch (int paramId, float minValue, float maxValue, float defaultValue, std::string name="", std::vector< std::string > labels={}) |
Helper for creating a SwitchQuantity and setting its label strings. | |
template<class TSwitchQuantity = SwitchQuantity> | |
TSwitchQuantity * | configButton (int paramId, std::string name="") |
Helper for creating a SwitchQuantity with no label. | |
template<class TPortInfo = PortInfo> | |
TPortInfo * | configInput (int portId, std::string name="") |
Helper for creating a PortInfo for an input port and setting its properties. | |
template<class TPortInfo = PortInfo> | |
TPortInfo * | configOutput (int portId, std::string name="") |
Helper for creating a PortInfo for an output port and setting its properties. | |
template<class TLightInfo = LightInfo> | |
TLightInfo * | configLight (int lightId, std::string name="") |
Helper for creating a LightInfo and setting its properties. | |
void | configBypass (int inputId, int outputId) |
Adds a direct route from an input to an output when the module is bypassed. | |
std::string | createPatchStorageDirectory () |
Creates and returns the module's patch storage directory path. | |
std::string | getPatchStorageDirectory () |
plugin::Model * | getModel () |
Getters for members. | |
int64_t | getId () |
int | getNumParams () |
Param & | getParam (int index) |
int | getNumInputs () |
Input & | getInput (int index) |
int | getNumOutputs () |
Output & | getOutput (int index) |
int | getNumLights () |
Light & | getLight (int index) |
ParamQuantity * | getParamQuantity (int index) |
PortInfo * | getInputInfo (int index) |
PortInfo * | getOutputInfo (int index) |
LightInfo * | getLightInfo (int index) |
Expander & | getLeftExpander () |
Expander & | getRightExpander () |
Expander & | getExpander (uint8_t side) |
Returns the left Expander for side = 0 and the right Expander for side = 1 . | |
virtual void | process (const ProcessArgs &args) |
Advances the module by one audio sample. | |
virtual void | step () |
DEPRECATED. | |
virtual void | processBypass (const ProcessArgs &args) |
Called instead of process() when Module is bypassed. | |
virtual json_t * | toJson () |
Usually you should override dataToJson() instead. | |
virtual void | fromJson (json_t *rootJ) |
This is virtual only for the purpose of unserializing legacy data when you could set properties of the .modules[] object itself. | |
virtual json_t * | paramsToJson () |
Serializes the "params" object. | |
virtual void | paramsFromJson (json_t *rootJ) |
virtual json_t * | dataToJson () |
Override to store extra internal data in the "data" property of the module's JSON object. | |
virtual void | dataFromJson (json_t *rootJ) |
Override to load internal data from the "data" property of the module's JSON object. | |
virtual void | onAdd (const AddEvent &e) |
Called after adding the module to the Engine. | |
virtual void | onRemove (const RemoveEvent &e) |
Called before removing the module from the Engine. | |
virtual void | onBypass (const BypassEvent &e) |
Called after bypassing the module. | |
virtual void | onUnBypass (const UnBypassEvent &e) |
Called after enabling the module. | |
virtual void | onPortChange (const PortChangeEvent &e) |
Called after a cable connects to or disconnects from a port. | |
virtual void | onSampleRateChange (const SampleRateChangeEvent &e) |
Called when the Engine sample rate changes, and when the Module is added to the Engine. | |
virtual void | onExpanderChange (const ExpanderChangeEvent &e) |
Called after an expander is added, removed, or changed on either the left or right side of the Module. | |
virtual void | onReset (const ResetEvent &e) |
Called when the user resets (initializes) the module. | |
virtual void | onRandomize (const RandomizeEvent &e) |
Called when the user randomizes the module. | |
virtual void | onSave (const SaveEvent &e) |
Called when the user saves the patch to a file. | |
virtual void | onSetMaster (const SetMasterEvent &e) |
virtual void | onUnsetMaster (const UnsetMasterEvent &e) |
virtual void | onAdd () |
DEPRECATED. | |
virtual void | onRemove () |
DEPRECATED. | |
virtual void | onReset () |
DEPRECATED. | |
virtual void | onRandomize () |
DEPRECATED. | |
virtual void | onSampleRateChange () |
DEPRECATED. | |
bool | isBypassed () |
PRIVATE void | setBypassed (bool bypassed) |
PRIVATE const float * | meterBuffer () |
PRIVATE int | meterLength () |
PRIVATE int | meterIndex () |
PRIVATE void | doProcess (const ProcessArgs &args) |
PRIVATE void | setExpanderModule (Module *module, uint8_t side) |
Sets module of expander and dispatches ExpanderChangeEvent if changed. | |
Static Public Member Functions | |
static PRIVATE void | jsonStripIds (json_t *rootJ) |
Public Attributes | |
Internal * | internal |
plugin::Model * | model = NULL |
Not owned. | |
int64_t | id = -1 |
Unique ID for referring to the module in the engine. | |
std::vector< Param > | params |
Arrays of components. | |
std::vector< Input > | inputs |
std::vector< Output > | outputs |
std::vector< Light > | lights |
std::vector< ParamQuantity * > | paramQuantities |
Arrays of component metadata. | |
std::vector< PortInfo * > | inputInfos |
std::vector< PortInfo * > | outputInfos |
std::vector< LightInfo * > | lightInfos |
Expander | leftExpander |
Expander | rightExpander |
std::vector< BypassRoute > | bypassRoutes |
DSP processor instance for your module.
rack::engine::Module::Module | ( | ) |
Constructs a Module with no params, inputs, outputs, and lights.
|
inline |
Use config() instead.
|
virtual |
void rack::engine::Module::config | ( | int | numParams, |
int | numInputs, | ||
int | numOutputs, | ||
int | numLights = 0 ) |
Configures the number of Params, Outputs, Inputs, and Lights.
Should only be called from a Module subclass's constructor.
|
inline |
Helper for creating a ParamQuantity and setting its properties.
See ParamQuantity for documentation of arguments. Should only be called from a Module subclass's constructor.
|
inline |
Helper for creating a SwitchQuantity and setting its label strings.
See ParamQuantity and SwitchQuantity for documentation of arguments. Should only be called from a Module subclass's constructor.
|
inline |
Helper for creating a SwitchQuantity with no label.
Should only be called from a Module subclass's constructor.
|
inline |
|
inline |
|
inline |
|
inline |
Adds a direct route from an input to an output when the module is bypassed.
Should only be called from a Module subclass's constructor.
std::string rack::engine::Module::createPatchStorageDirectory | ( | ) |
Creates and returns the module's patch storage directory path.
Do not call this method in process() since filesystem operations block the audio thread.
Throws an Exception if Module is not yet added to the Engine. Therefore, you may not call these methods in your Module constructor. Instead, load patch storage files in onAdd() and save them in onSave().
Patch storage files of deleted modules are garbage collected when user saves the patch. To allow the Undo feature to restore patch storage if the module is accidentally deleted, it is recommended to not delete patch storage in onRemove().
std::string rack::engine::Module::getPatchStorageDirectory | ( | ) |
|
inline |
Getters for members.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
Advances the module by one audio sample.
Override this method to read Inputs and Params and to write Outputs and Lights.
|
inlinevirtual |
DEPRECATED.
Override process(const ProcessArgs& args)
instead.
|
virtual |
Called instead of process() when Module is bypassed.
Typically you do not need to override this. Use configBypass() instead. If you do override it, avoid reading param values, since the state of the module should have no effect on routing.
|
virtual |
Usually you should override dataToJson() instead.
There are very few reasons you should override this (perhaps to lock a mutex while serialization is occurring).
|
virtual |
This is virtual only for the purpose of unserializing legacy data when you could set properties of the .modules[]
object itself.
Normally you should override dataFromJson(). Remember to call Module::fromJson(rootJ)
within your overridden method.
|
virtual |
Serializes the "params" object.
|
virtual |
|
inlinevirtual |
Override to store extra internal data in the "data" property of the module's JSON object.
|
inlinevirtual |
Override to load internal data from the "data" property of the module's JSON object.
Not called if "data" property is not present.
|
inlinevirtual |
Called after adding the module to the Engine.
|
inlinevirtual |
Called before removing the module from the Engine.
|
inlinevirtual |
Called after bypassing the module.
|
inlinevirtual |
Called after enabling the module.
|
inlinevirtual |
Called after a cable connects to or disconnects from a port.
This event is not called for output ports if a stackable cable was added/removed and did not change the port's connected state.
|
inlinevirtual |
|
inlinevirtual |
Called after an expander is added, removed, or changed on either the left or right side of the Module.
|
virtual |
Called when the user resets (initializes) the module.
The default implementation resets all parameters to their default value, so you must call Module::onReset(e)
in your overridden method if you want to keep this behavior.
|
virtual |
Called when the user randomizes the module.
The default implementation randomizes all parameters by default, so you must call Module::onRandomize(e)
in your overridden method if you want to keep this behavior.
|
inlinevirtual |
Called when the user saves the patch to a file.
If your module uses patch asset storage, make sure all files are saved in this event.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
DEPRECATED.
Override onAdd(e)
instead.
|
inlinevirtual |
DEPRECATED.
Override onRemove(e)
instead.
|
inlinevirtual |
DEPRECATED.
Override onReset(e)
instead.
|
inlinevirtual |
DEPRECATED.
Override onRandomize(e)
instead.
|
inlinevirtual |
DEPRECATED.
Override onSampleRateChange(e)
instead.
bool rack::engine::Module::isBypassed | ( | ) |
PRIVATE void rack::engine::Module::setBypassed | ( | bool | bypassed | ) |
PRIVATE const float * rack::engine::Module::meterBuffer | ( | ) |
PRIVATE int rack::engine::Module::meterLength | ( | ) |
PRIVATE int rack::engine::Module::meterIndex | ( | ) |
PRIVATE void rack::engine::Module::doProcess | ( | const ProcessArgs & | args | ) |
|
static |
Sets module of expander and dispatches ExpanderChangeEvent if changed.
Internal* rack::engine::Module::internal |
plugin::Model* rack::engine::Module::model = NULL |
Not owned.
int64_t rack::engine::Module::id = -1 |
Unique ID for referring to the module in the engine.
Between 0 and 2^53-1 since the number is serialized with JSON. Assigned when added to the engine.
std::vector<Param> rack::engine::Module::params |
Arrays of components.
Initialized using config().
It is recommended to call getParam(), getInput(), etc. instead of accessing these directly.
std::vector<Input> rack::engine::Module::inputs |
std::vector<Output> rack::engine::Module::outputs |
std::vector<Light> rack::engine::Module::lights |
std::vector<ParamQuantity*> rack::engine::Module::paramQuantities |
Arrays of component metadata.
Initialized using configParam(), configInput(), configOutput(), and configLight(). LightInfos are initialized to null unless configLight() is called.
It is recommended to call getParamQuantity(), getInputInfo(), etc. instead of accessing these directly.
std::vector<PortInfo*> rack::engine::Module::inputInfos |
std::vector<PortInfo*> rack::engine::Module::outputInfos |
std::vector<LightInfo*> rack::engine::Module::lightInfos |
Expander rack::engine::Module::leftExpander |
Expander rack::engine::Module::rightExpander |
std::vector<BypassRoute> rack::engine::Module::bypassRoutes |