|
iPlug2 - C++ Audio Plug-in Framework
|
IPlugFaust is the base class for hosting a Faust DSP inside an iPlug2 plug-in. More...
#include <IPlugFaust.h>
Public Member Functions | |
| IPlugFaust (const char *name, int nVoices=0, int ctrlTagStart=kDefaultCtrlTagStart) | |
| IPlugFaust (const IPlugFaust &)=delete | |
| IPlugFaust & | operator= (const IPlugFaust &)=delete |
| virtual void | Init ()=0 |
| Create the DSP. More... | |
| void | SetMaxChannelCount (int maxNInputs, int maxNOutputs) |
| Tell IPlugFaust the maximum number of channels the plug-in provides, if the DSP needs more it will output silence. More... | |
| void | SetSampleRate (double sampleRate) |
| Call this from the plug-in's OnReset(). More... | |
| void | ProcessMidiMsg (const IMidiMsg &msg) |
| Call this from the plug-in's ProcessMidiMsg() More... | |
| void | ProcessBlock (sample **inputs, sample **outputs, int nFrames) |
| Call this from the plug-in's ProcessBlock(). More... | |
| bool | IsReady () const |
| int | NInputs () const |
| int | NOutputs () const |
| int | GetMaxNInputs () const |
| int | GetMaxNOutputs () const |
| int | NParams () const |
| int | CreateIPlugParameters (IPlugAPIBase *pPlug, int startIdx=0, int endIdx=-1, bool setToDefault=true) |
| Initialize the plug-in's parameters startIdx...startIdx+NParams() from the Faust widgets, and link them. More... | |
| bool | OnParamChange (int plugParamIdx) |
| If plugParamIdx is linked to a Faust widget, update its zone from the plug-in's parameter value. More... | |
| void | SetParameterValueNormalised (int faustParamIdx, double normalizedValue) |
| Set a Faust widget's value via its parameter index (0...NParams()-1) More... | |
| void | SetParameterValue (int faustParamIdx, double value) |
| Set a Faust widget's value via its parameter index (0...NParams()-1) More... | |
| void | SetParameterValue (const char *labelOrPath, double value) |
| Set a Faust widget's value via its label or full path (e.g. More... | |
| void | SyncFaustParams () |
| Apply the values of all the parameters to the DSP (e.g. More... | |
| int | GetFaustParamIdxForZone (FAUSTFLOAT *zone) const |
| int | GetPlugParamIdx (int faustParamIdx) const |
| const FaustUIItem & | GetUIRoot () const |
| const char * | GetJSON () const |
| void | BuildUI (UI *pUI) |
| Calls buildUserInterface() and metadata() on the DSP, to build a Faust UI. More... | |
| void | openTabBox (const char *label) override |
| void | openHorizontalBox (const char *label) override |
| void | openVerticalBox (const char *label) override |
| void | closeBox () override |
| void | addButton (const char *label, FAUSTFLOAT *zone) override |
| void | addCheckButton (const char *label, FAUSTFLOAT *zone) override |
| void | addVerticalSlider (const char *label, FAUSTFLOAT *zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) override |
| void | addHorizontalSlider (const char *label, FAUSTFLOAT *zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) override |
| void | addNumEntry (const char *label, FAUSTFLOAT *zone, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step) override |
| void | addHorizontalBargraph (const char *label, FAUSTFLOAT *zone, FAUSTFLOAT min, FAUSTFLOAT max) override |
| void | addVerticalBargraph (const char *label, FAUSTFLOAT *zone, FAUSTFLOAT min, FAUSTFLOAT max) override |
| void | addSoundfile (const char *label, const char *filename, Soundfile **sfZone) override |
| void | declare (FAUSTFLOAT *zone, const char *key, const char *value) override |
Static Public Attributes | |
| static constexpr int | kDefaultCtrlTagStart = 1000 |
Protected Member Functions | |
| void | SetDSP (::dsp *pMonoDSP) |
| Takes ownership of a newly created DSP, wraps it for polyphony if required, (re)builds the parameters and UI description and swaps it in. More... | |
| void | ReleaseDSP () |
| Destroys the DSP, waiting for a block that is being processed to finish first. More... | |
| void | InformHostIfParamsChanged () |
| If SetDSP() re-initialized the linked plug-in parameters (i.e. More... | |
Protected Attributes | |
| WDL_String | mName |
IPlugFaust is the base class for hosting a Faust DSP inside an iPlug2 plug-in.
It maps the Faust DSP's widgets to IPlug parameters, routes MIDI to the DSP (including polyphony via the "[nvoices:N]" option), sends bargraph values to the editor and keeps a description of the Faust UI that UI builders can use.
There are two implementations which share this interface:
Definition at line 105 of file IPlugFaust.h.
| IPlugFaust::IPlugFaust | ( | const char * | name, |
| int | nVoices = 0, |
||
| int | ctrlTagStart = kDefaultCtrlTagStart |
||
| ) |
| name | A name for the DSP, used for logging |
| nVoices | Number of polyphonic voices to use if the DSP doesn't declare "[nvoices:N]" in its options metadata. Values < 2 mean monophonic. |
| ctrlTagStart | The first control tag used for bargraphs. Bargraphs are given consecutive tags in the order they are declared. |
Definition at line 44 of file IPlugFaust.cpp.
|
virtual |
Definition at line 51 of file IPlugFaust.cpp.
|
override |
Definition at line 669 of file IPlugFaust.cpp.
|
override |
Definition at line 675 of file IPlugFaust.cpp.
|
override |
Definition at line 723 of file IPlugFaust.cpp.
|
override |
Definition at line 688 of file IPlugFaust.cpp.
|
override |
Definition at line 695 of file IPlugFaust.cpp.
|
override |
Definition at line 733 of file IPlugFaust.cpp.
|
override |
Definition at line 728 of file IPlugFaust.cpp.
|
override |
Definition at line 681 of file IPlugFaust.cpp.
| void IPlugFaust::BuildUI | ( | UI * | pUI | ) |
Calls buildUserInterface() and metadata() on the DSP, to build a Faust UI.
Only call this on the main thread.
Definition at line 486 of file IPlugFaust.cpp.
|
override |
Definition at line 554 of file IPlugFaust.cpp.
| int IPlugFaust::CreateIPlugParameters | ( | IPlugAPIBase * | pPlug, |
| int | startIdx = 0, |
||
| int | endIdx = -1, |
||
| bool | setToDefault = true |
||
| ) |
Initialize the plug-in's parameters startIdx...startIdx+NParams() from the Faust widgets, and link them.
The plug-in must have enough parameters, so for a JIT compiled DSP that may change, allocate some spare ones. After linking, the IPlug parameter values are applied to the DSP in SetParameterValueNormalised().
| pPlug | The plug-in |
| startIdx | The index of the first plug-in parameter to use |
| endIdx | The index after the last Faust parameter to link, or -1 for all of them |
| setToDefault | If true the parameters are set to their default values, otherwise the current normalized values are kept |
Definition at line 139 of file IPlugFaust.cpp.
References IParam::GetNormalized(), IParam::Init(), NParams(), IParam::SetNormalized(), IParam::SetToDefault(), and SyncFaustParams().
|
override |
Definition at line 740 of file IPlugFaust.cpp.
| int IPlugFaust::GetFaustParamIdxForZone | ( | FAUSTFLOAT * | zone | ) | const |
Definition at line 254 of file IPlugFaust.cpp.
References NParams().
|
inline |
Definition at line 195 of file IPlugFaust.h.
|
inline |
Definition at line 142 of file IPlugFaust.h.
|
inline |
Definition at line 143 of file IPlugFaust.h.
| int IPlugFaust::GetPlugParamIdx | ( | int | faustParamIdx | ) | const |
Definition at line 265 of file IPlugFaust.cpp.
Referenced by IGraphicsFaustUI::CreateControl(), SetDSP(), and SyncFaustParams().
|
inline |
Definition at line 192 of file IPlugFaust.h.
Referenced by IGraphicsFaustUI::CreateControl().
|
protected |
If SetDSP() re-initialized the linked plug-in parameters (i.e.
the DSP was replaced), tell the host to re-read the parameter details. Call this on the main thread, after the plug-in has finished updating its parameters
Definition at line 356 of file IPlugFaust.cpp.
References IPluginBase::InformHostOfParameterDetailsChange().
|
pure virtual |
Create the DSP.
Call this once after construction (and after SetMaxChannelCount)
Implemented in FaustGen.
|
inline |
true if a DSP has been created and can be processed (it fits the channel count and doesn't use soundfiles) Definition at line 138 of file IPlugFaust.h.
|
inline |
Definition at line 140 of file IPlugFaust.h.
|
inline |
Definition at line 141 of file IPlugFaust.h.
|
inline |
Definition at line 148 of file IPlugFaust.h.
Referenced by IGraphicsFaustUI::CreateControl(), CreateIPlugParameters(), GetFaustParamIdxForZone(), SetDSP(), SetParameterValue(), SetParameterValueNormalised(), and SyncFaustParams().
| bool IPlugFaust::OnParamChange | ( | int | plugParamIdx | ) |
If plugParamIdx is linked to a Faust widget, update its zone from the plug-in's parameter value.
Call this from the plug-in's OnParamChange().
true if the parameter belongs to this DSP Definition at line 178 of file IPlugFaust.cpp.
|
override |
Definition at line 544 of file IPlugFaust.cpp.
|
override |
Definition at line 539 of file IPlugFaust.cpp.
|
override |
Definition at line 549 of file IPlugFaust.cpp.
| void IPlugFaust::ProcessBlock | ( | sample ** | inputs, |
| sample ** | outputs, | ||
| int | nFrames | ||
| ) |
Call this from the plug-in's ProcessBlock().
Unused output channels are cleared.
Definition at line 115 of file IPlugFaust.cpp.
| void IPlugFaust::ProcessMidiMsg | ( | const IMidiMsg & | msg | ) |
Call this from the plug-in's ProcessMidiMsg()
Definition at line 105 of file IPlugFaust.cpp.
|
protected |
Destroys the DSP, waiting for a block that is being processed to finish first.
Call it on the main thread. Subclasses that own something the DSP depends on (e.g. the factory that created it) must call this in their destructor
Definition at line 56 of file IPlugFaust.cpp.
|
protected |
Takes ownership of a newly created DSP, wraps it for polyphony if required, (re)builds the parameters and UI description and swaps it in.
Everything is prepared first. The swap itself only exchanges pointers, while the audio thread outputs silence (at most one block), so it is safe to call while processing. Call it on the main thread.
| pMonoDSP | The new DSP instance |
Definition at line 367 of file IPlugFaust.cpp.
References Timer::Create(), FAUST_UI_INTERVAL, GetPlugParamIdx(), NParams(), and SyncFaustParams().
| void IPlugFaust::SetMaxChannelCount | ( | int | maxNInputs, |
| int | maxNOutputs | ||
| ) |
Tell IPlugFaust the maximum number of channels the plug-in provides, if the DSP needs more it will output silence.
| maxNInputs | Maximum number of input channels |
| maxNOutputs | Maximum number of output channels |
Definition at line 85 of file IPlugFaust.cpp.
| void IPlugFaust::SetParameterValue | ( | const char * | labelOrPath, |
| double | value | ||
| ) |
Set a Faust widget's value via its label or full path (e.g.
"freq" or "/synth/freq"). This doesn't update linked IPlug parameters. It compares strings to find the widget, so it is not meant for the audio thread: use the index overload there.
| labelOrPath | The label or full path of the widget |
| value | The non-normalized value (for menus and radio buttons, the index of the item) |
Definition at line 214 of file IPlugFaust.cpp.
References NParams().
| void IPlugFaust::SetParameterValue | ( | int | faustParamIdx, |
| double | value | ||
| ) |
Set a Faust widget's value via its parameter index (0...NParams()-1)
| faustParamIdx | The index of the Faust parameter |
| value | The non-normalized value (for menus and radio buttons, the index of the item) |
Definition at line 209 of file IPlugFaust.cpp.
| void IPlugFaust::SetParameterValueNormalised | ( | int | faustParamIdx, |
| double | normalizedValue | ||
| ) |
Set a Faust widget's value via its parameter index (0...NParams()-1)
| faustParamIdx | The index of the Faust parameter |
| normalizedValue | The normalized [0, 1] value |
Definition at line 192 of file IPlugFaust.cpp.
References NParams().
| void IPlugFaust::SetSampleRate | ( | double | sampleRate | ) |
Call this from the plug-in's OnReset().
It re-initializes the DSP, waiting for a block that is being processed to finish first, so don't call it from ProcessBlock()
Definition at line 91 of file IPlugFaust.cpp.
References SyncFaustParams().
| void IPlugFaust::SyncFaustParams | ( | ) |
Apply the values of all the parameters to the DSP (e.g.
after dsp::init() has reset the zones)
Definition at line 235 of file IPlugFaust.cpp.
References GetPlugParamIdx(), and NParams().
Referenced by CreateIPlugParameters(), SetDSP(), and SetSampleRate().
|
staticconstexpr |
Definition at line 108 of file IPlugFaust.h.
|
protected |
Definition at line 231 of file IPlugFaust.h.