ASPiK SDK
Loading...
Searching...
No Matches
Coding the Plugin Parameters with Variable Binding

At this point, you can open up the ASPiK Tool-Kit application that is part of the SDK and use the GUI Code Creator to generate the C++ code for both the bound variable as well as the PluginParameter declaration and instantiation. NOTE: this is optional and you may always code the plugin parameters by hand. The ASPiK GUI Code Creator is useful for starting out and you can always tweak and modify the code it gerenates. Open the ASPiK Tool-Kit and switch to the GUI Code Creator. The first entry in the GUI control table is for the continuous Volume in dB control (this will map to a continous knob control on the GUI). Select the "Continuous Numeric" control type and fill in the information for the PluginParameter and the bound variable from the table. Notice how the variable name "volume_dB" matches the unique control identifier which also matches the previously declared enumeration. Also, since this is our first parameter, we have c checked the "Include PluginParamater* declaration" box - you only need to do this once for the first parameter you define.


With this data set, you can now generate the C++ code and paste it into your plugin project:

Bound Variable Code:
goes in the plugincore.h file in the "private" area provided for your member variables; click the [Var -> Clipboard] button to copy the code to the clipboard, then paste it into the plugincore.h file; note that it will add a default declaration value based on the default value you declared in the GUI Code Creator app.

//
class PluginCore : public PluginBase
{
public:
virtual ~PluginCore(){}
// SNIP SNIP SNIP...
private:
// --- Continuous Plugin Variables
double volume_dB = 0.000000; // <-- bound member variable!
// etc...
The PluginBase object is the base class for the Plugin Core object.
Definition: pluginbase.h:42
The PluginCore object is the default PluginBase derived object for ASPiK projects....
Definition: plugincore.h:44
PluginCore()
PluginCore constructor is launching pad for object initialization.
Definition: plugincore.cpp:25
virtual ~PluginCore()
Definition: plugincore.h:49

PluginParameter instantiation Code:
goes in the PluginCore::initPluginParameters( ) function at the top just after the if (pluginParameterMap.size() > 0) statement. Click the [Code -> Clinpbaord] button to copy the code to the clipboard, then paste it into the PluginCore::initPluginParameters( ) function;

//
{
if (pluginParameterMap.size() > 0)
return true;
PluginParameter* piParam = nullptr;
/* Volume control that is linear in dB */
piParam = new PluginParameter(controlID::volume_dB, "Volume", "dB",
controlVariableType::kDouble, -60.000000, 12.000000, 0.000000,
taper::kLinearTaper);
piParam->setBoundVariable(&volume_dB, boundVariableType::kDouble);
addPluginParameter(piParam);
etc...
//
int32_t addPluginParameter(PluginParameter *piParam, double sampleRate=44100)
adds a new plugin parameter to the parameter map
Definition: pluginbase.cpp:428
pluginParameterControlIDMap pluginParameterMap
member map of parameter list
Definition: pluginbase.h:447
bool initPluginParameters()
create all of your plugin parameters here
Definition: plugincore.cpp:643
The PluginParameter object stores all of the data needed for any type of plugin parameter....
Definition: pluginparameter.h:52
void setBoundVariable(void *boundVariable, boundVariableType dataType)
save the variable for binding operation
Definition: pluginparameter.h:461


Parameter Smoothing
ASPiK features automatic parameter smoothing for continuous controls. It can be applied to any continuous control and is a local option, that is, it can be applied to individual parameters (or not at all) and parameters can have different parameter smoothing times (see the Pirkle text for much more information). Most programmers will use the same smoothing time for the majority of their controls. Therefore, parameter smoothing is set on the ASPiK Project Creator panel as a sort of global option. To use it, just open the ASPiK Project Creator panel and check the box along with a default smoothing time in milliseconds. You don't need to create a new project or anything - the parameter smoothing time is the only data that carries over into the GUI Code Creator panel. If you set up parameter smoothing you will have a few more lines of code added - note that you may manipulate the functions later to turn off parameter smoothing or change the smoothing time. These additional lines will be added after the instantiation:

//
piParam->setParameterSmoothing(true);
piParam->setSmoothingTimeMsec(20.000000);
//
void setParameterSmoothing(bool value)
set inverted meter flag
Definition: pluginparameter.h:144
void setSmoothingTimeMsec(double value)
set inverted meter flag
Definition: pluginparameter.h:147

Now you can add the other member variables. Next up is the Mute switch; it is implemented as a String-List parameter with two strings: OFF and ON that determine its state. Hit the [Reset] button on the GUI Code Creator to clear out the last entry. Then, select the "String List Switch (ON, OFF)" parameter type. In this case, we will use the default string list of OFF,ON and set the default to the OFF (0) state. Note that you can name the pair of strings however you like (e.g. ENABLED, DISABLED or OUI, NON) knowing that the first string will map to the value (0) while the second maps to (1). Notice also that we've de-selected the "Include PluginParameter*..." switch.


You can now add the bound variable to the plugincore.h file and the parameter instantiation code to the plugincore.cpp file as before, pasting the code in sequence. First, notice how the String-List bound variable declaration resulted in two lines of code; one for the GUI control receiver variable (enableMute) and the other as a strongly typed enumeration that uses the variable name concatenated with "Enum" - this is to allow you to easily evaluate the state of the GUI control item using the built in MACROs that are listed in the SDK. You may decide to use other methods to identify the state of the receiver variable if you wish, but we use the strongly typed enumeration method in the sample code. In ASPiK, String-List controls are ALWAYS bound to variables with the int data-type and using the [Var -> Clipboard] feature will always bind an integer type regardless of what you choose in the drop-list.

//
private:
// --- Continuous Plugin Variables
double volume_dB = 0.000000;
// --- String-List Plugin Variables
int enableMute = 0;
enum class enableMuteEnum { "OFF,ON" };
//

Next, you can paste the code for the string list parameter just below the instantiation for the first parameter:

//
/* Simple mute control - default value is OFF */
piParam = new PluginParameter(controlID::enableMute, "Mute", "OFF,ON", "OFF");
piParam->setBoundVariable(&enableMute, boundVariableType::kInt);
addPluginParameter(piParam);
//


Next up is the channel selection GUI control. This is done with another String-List, but this one will need more than just two states. Reset the GUI Control Creator and select the "String List Switch (multiple taps)" parameter, then enter the information from the GUI control table. Notice that you specify the default value with an unsigned integer index - the list is zero-indexed, so the first item is number 0, the second is 1, etc...


Once again use the [Var -> Clipboard] and [Code -> Clipboard] buttons to generate and paste the code into your plugincore.h and plugincore.cpp files:

//
private:
// --- Continuous Plugin Variables
double volume_dB = 0.000000;
// --- String-List Plugin Variables
int enableMute = 0;
enum class enableMuteEnum { "OFF,ON" };
int channels = 0;
enum class channelsEnum { "stereo, left, right" };
//

Then, you can paste the code for the string list parameter just below the instantiation for the first parameter:

//
/* Channel selector */
piParam = new PluginParameter(controlID::channels, "Channel Select", "stereo, left, right", "stereo");
piParam->setBoundVariable(&channels, boundVariableType::kInt);
addPluginParameter(piParam);
//

Our last parameter to encode is an output parameter in the form of a VU meter on the GUI. In ASPiK, meter controls are ALWAYS bound to variables with the float data-type and using the [Var -> Clipboard] feature will always bind a floating point type regardless of what you choose in the drop-list. Once again reset the GUI Control Creator panel and select the "Meter" parameter type, then add the information from the GUI control table like before.



Once again use the [Var -> Clipboard] and [Code -> Clipboard] buttons to generate and paste the code into your plugincore.h and plugincore.cpp files:

//
private:
// --- Continuous Plugin Variables
double volume_dB = 0.000000;
// --- String-List Plugin Variables
int enableMute = 0;
enum class enableMuteEnum { "OFF,ON" };
int channels = 0;
enum class channelsEnum { "stereo, left, right" };
float vuMeter = 0.0;

Then, you can paste the code for the VU meter parameter just below the instantiation for the last parameter:

//
/* Log VU meter control */
piParam = new PluginParameter(controlID::vuMeter, "Control", 10.00, 500.00, ENVELOPE_DETECT_MODE_RMS, meterCal::kLogMeter);
piParam->setInvertedMeter(false);
piParam->setIsProtoolsGRMeter(false);
piParam->setBoundVariable(&vuMeter, boundVariableType::kFloat);
addPluginParameter(piParam);
//
void setIsProtoolsGRMeter(bool value)
set inverted meter flag
Definition: pluginparameter.h:141
void setInvertedMeter(bool value)
set inverted meter flag
Definition: pluginparameter.h:138
const uint32_t ENVELOPE_DETECT_MODE_RMS
SQRT((1/N)|x|^2)
Definition: guiconstants.h:201

At this point, all of the plugin bound variables and plugin parameters have been declared and defined. We can now move on to the plugin's reset operation.