111 config(numParams, numInputs, numOutputs, numLights);
118 void config(
int numParams,
int numInputs,
int numOutputs,
int numLights = 0);
124 template <
class TParamQuantity = ParamQuantity>
125 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) {
130 TParamQuantity* q =
new TParamQuantity;
131 q->ParamQuantity::module =
this;
132 q->ParamQuantity::paramId = paramId;
133 q->ParamQuantity::minValue = minValue;
134 q->ParamQuantity::maxValue = maxValue;
135 q->ParamQuantity::defaultValue = defaultValue;
136 q->ParamQuantity::name = name;
137 q->ParamQuantity::unit = unit;
138 q->ParamQuantity::displayBase = displayBase;
139 q->ParamQuantity::displayMultiplier = displayMultiplier;
140 q->ParamQuantity::displayOffset = displayOffset;
144 p->
value = q->getDefaultValue();
152 template <
class TSwitchQuantity = SwitchQuantity>
153 TSwitchQuantity*
configSwitch(
int paramId,
float minValue,
float maxValue,
float defaultValue, std::string name =
"", std::vector<std::string> labels = {}) {
155 sq->ParamQuantity::snapEnabled =
true;
156 sq->ParamQuantity::smoothEnabled =
false;
157 sq->SwitchQuantity::labels = labels;
164 template <
class TSwitchQuantity = SwitchQuantity>
167 sq->ParamQuantity::snapEnabled =
true;
168 sq->ParamQuantity::smoothEnabled =
false;
169 sq->ParamQuantity::randomizeEnabled =
false;
177 template <
class TPortInfo = PortInfo>
183 TPortInfo* info =
new TPortInfo;
184 info->PortInfo::module =
this;
186 info->PortInfo::portId = portId;
187 info->PortInfo::name = name;
196 template <
class TPortInfo = PortInfo>
202 TPortInfo* info =
new TPortInfo;
203 info->PortInfo::module =
this;
205 info->PortInfo::portId = portId;
206 info->PortInfo::name = name;
216 template <
class TLightInfo = LightInfo>
222 TLightInfo* info =
new TLightInfo;
223 info->LightInfo::module =
this;
224 info->LightInfo::lightId = lightId;
225 info->LightInfo::name = name;
234 assert(inputId < (
int)
inputs.size());
235 assert(outputId < (
int)
outputs.size());
240 assert(br.outputId != outputId);
#define PRIVATE
Attribute for private functions not intended to be called by plugins.
Definition common.hpp:32
#define DEPRECATED
Attribute for deprecated functions and symbols.
Definition common.hpp:26
std::string plugin(plugin::Plugin *plugin, std::string filename="")
Returns the path of an asset in the plugin's dir.
Root namespace for the Rack API.
Definition AudioDisplay.hpp:9
Definition LightInfo.hpp:12
Definition Module.hpp:373
Definition Module.hpp:389
Definition Module.hpp:101
int inputId
Definition Module.hpp:102
int outputId
Definition Module.hpp:103
Definition Module.hpp:422
uint8_t side
0 for left, 1 for right.
Definition Module.hpp:424
Represents a message-passing channel for an adjacent module.
Definition Module.hpp:64
void * consumerMessage
Definition Module.hpp:90
int64_t moduleId
ID of the expander module, or -1 if nonexistent.
Definition Module.hpp:66
void requestMessageFlip()
Definition Module.hpp:93
void * producerMessage
Double buffer for receiving messages from the expander module.
Definition Module.hpp:89
bool messageFlipRequested
Definition Module.hpp:91
Definition Module.hpp:399
int portId
Definition Module.hpp:404
Port::Type type
Port::INPUT or Port::OUTPUT.
Definition Module.hpp:403
bool connecting
True if connecting, false if disconnecting.
Definition Module.hpp:401
Definition Module.hpp:318
float sampleTime
The timestep of process() in seconds.
Definition Module.hpp:324
float sampleRate
The current sample rate in Hz.
Definition Module.hpp:320
int64_t frame
Number of audio samples since the Engine's first sample.
Definition Module.hpp:326
Definition Module.hpp:436
Definition Module.hpp:381
Definition Module.hpp:430
Definition Module.hpp:411
float sampleTime
Definition Module.hpp:413
float sampleRate
Definition Module.hpp:412
Definition Module.hpp:442
Definition Module.hpp:448
Definition Module.hpp:394
Definition Module.hpp:451
DSP processor instance for your module.
Definition Module.hpp:29
std::vector< Input > inputs
Definition Module.hpp:48
virtual void onUnBypass(const UnBypassEvent &e)
Called after enabling the module.
Definition Module.hpp:397
int getNumInputs()
Definition Module.hpp:275
void configBypass(int inputId, int outputId)
Adds a direct route from an input to an output when the module is bypassed.
Definition Module.hpp:233
std::vector< LightInfo * > lightInfos
Definition Module.hpp:61
PRIVATE const float * meterBuffer()
virtual void onRemove()
DEPRECATED.
Definition Module.hpp:457
virtual void onAdd()
DEPRECATED.
Definition Module.hpp:455
Param & getParam(int index)
Definition Module.hpp:272
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.
Definition Module.hpp:153
Expander & getExpander(uint8_t side)
Returns the left Expander for side = 0 and the right Expander for side = 1.
Definition Module.hpp:312
virtual void processBypass(const ProcessArgs &args)
Called instead of process() when Module is bypassed.
int getNumLights()
Definition Module.hpp:287
virtual void onRandomize(const RandomizeEvent &e)
Called when the user randomizes the module.
virtual void onSampleRateChange()
DEPRECATED.
Definition Module.hpp:463
plugin::Model * getModel()
Getters for members.
Definition Module.hpp:263
virtual void onRandomize()
DEPRECATED.
Definition Module.hpp:461
std::string createPatchStorageDirectory()
Creates and returns the module's patch storage directory path.
virtual void onUnsetMaster(const UnsetMasterEvent &e)
Definition Module.hpp:452
virtual void onSave(const SaveEvent &e)
Called when the user saves the patch to a file.
Definition Module.hpp:446
PRIVATE int meterLength()
Expander rightExpander
Definition Module.hpp:99
static PRIVATE void jsonStripIds(json_t *rootJ)
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.
Definition Module.hpp:125
TLightInfo * configLight(int lightId, std::string name="")
Helper for creating a LightInfo and setting its properties.
Definition Module.hpp:217
virtual void onReset()
DEPRECATED.
Definition Module.hpp:459
virtual void onSetMaster(const SetMasterEvent &e)
Definition Module.hpp:449
Input & getInput(int index)
Definition Module.hpp:278
virtual void onBypass(const BypassEvent &e)
Called after bypassing the module.
Definition Module.hpp:392
virtual json_t * toJson()
Usually you should override dataToJson() instead.
virtual void process(const ProcessArgs &args)
Advances the module by one audio sample.
Definition Module.hpp:331
void config(int numParams, int numInputs, int numOutputs, int numLights=0)
Configures the number of Params, Outputs, Inputs, and Lights.
std::vector< Output > outputs
Definition Module.hpp:49
Internal * internal
Definition Module.hpp:31
Light & getLight(int index)
Definition Module.hpp:290
std::vector< Param > params
Arrays of components.
Definition Module.hpp:47
virtual json_t * dataToJson()
Override to store extra internal data in the "data" property of the module's JSON object.
Definition Module.hpp:359
std::vector< BypassRoute > bypassRoutes
Definition Module.hpp:105
virtual void onRemove(const RemoveEvent &e)
Called before removing the module from the Engine.
Definition Module.hpp:384
TPortInfo * configInput(int portId, std::string name="")
Helper for creating a PortInfo for an input port and setting its properties.
Definition Module.hpp:178
Module()
Constructs a Module with no params, inputs, outputs, and lights.
Expander leftExpander
Definition Module.hpp:98
virtual void dataFromJson(json_t *rootJ)
Override to load internal data from the "data" property of the module's JSON object.
Definition Module.hpp:365
virtual void paramsFromJson(json_t *rootJ)
virtual void onAdd(const AddEvent &e)
Called after adding the module to the Engine.
Definition Module.hpp:376
TSwitchQuantity * configButton(int paramId, std::string name="")
Helper for creating a SwitchQuantity with no label.
Definition Module.hpp:165
TPortInfo * configOutput(int portId, std::string name="")
Helper for creating a PortInfo for an output port and setting its properties.
Definition Module.hpp:197
DEPRECATED Module(int numParams, int numInputs, int numOutputs, int numLights=0)
Use config() instead.
Definition Module.hpp:110
virtual void onPortChange(const PortChangeEvent &e)
Called after a cable connects to or disconnects from a port.
Definition Module.hpp:409
ParamQuantity * getParamQuantity(int index)
Definition Module.hpp:293
Expander & getRightExpander()
Definition Module.hpp:308
PRIVATE void setExpanderModule(Module *module, uint8_t side)
Sets module of expander and dispatches ExpanderChangeEvent if changed.
PRIVATE void setBypassed(bool bypassed)
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...
Definition Module.hpp:428
PRIVATE void doProcess(const ProcessArgs &args)
virtual void step()
DEPRECATED.
Definition Module.hpp:336
Output & getOutput(int index)
Definition Module.hpp:284
virtual void onSampleRateChange(const SampleRateChangeEvent &e)
Called when the Engine sample rate changes, and when the Module is added to the Engine.
Definition Module.hpp:417
plugin::Model * model
Not owned.
Definition Module.hpp:34
PortInfo * getOutputInfo(int index)
Definition Module.hpp:299
PortInfo * getInputInfo(int index)
Definition Module.hpp:296
std::vector< PortInfo * > inputInfos
Definition Module.hpp:59
int64_t id
Unique ID for referring to the module in the engine.
Definition Module.hpp:40
Expander & getLeftExpander()
Definition Module.hpp:305
std::vector< PortInfo * > outputInfos
Definition Module.hpp:60
std::vector< ParamQuantity * > paramQuantities
Arrays of component metadata.
Definition Module.hpp:58
virtual void onReset(const ResetEvent &e)
Called when the user resets (initializes) the module.
LightInfo * getLightInfo(int index)
Definition Module.hpp:302
int getNumOutputs()
Definition Module.hpp:281
virtual void fromJson(json_t *rootJ)
This is virtual only for the purpose of unserializing legacy data when you could set properties of th...
std::string getPatchStorageDirectory()
std::vector< Light > lights
Definition Module.hpp:50
int getNumParams()
Definition Module.hpp:269
int64_t getId()
Definition Module.hpp:266
virtual json_t * paramsToJson()
Serializes the "params" object.
A Quantity that wraps an engine::Param.
Definition ParamQuantity.hpp:21
float value
Unstable API.
Definition Param.hpp:12
Definition PortInfo.hpp:13
Type
Definition Port.hpp:37
@ OUTPUT
Definition Port.hpp:39
@ INPUT
Definition Port.hpp:38
Type information for a module.
Definition Model.hpp:34