SynthLab SDK
Parameter Structures

All of the SynthModule objects use a pre-defined custom data structure specifically for object parameters that may be changed via the GUI or programmatically. This structure is NOT for modulation which is done with separate modulation arrays. You can think of the "parameters" as anything that could be connected to a GUI control for the user. On occasion, you will see use of the parameters to hold cooked values from GUI control, that are used later in the module's render operation.

getParameters( )

You will use the parameter structure to update the object as a result of GUI manipulation, or to progammatically set values without (or in addition to) the GUI. All SynthModules feature the same-named function called getParameters( ) which returns a std::shared_ptr to the parameter structure. The type of pointer returned depends on the owning object; the SynthLFO object uses the LFOParameters structure. All of the custom parameter structures are coded in the synthlabparams.h file along with constants used specifically with them. For example, the LFOParameters transmits a waveform index value that indicates the LFO waveform that the user has chosen. To make the code easier to read and maintain, a strongly typed enum is defined for the waveforms:

enum class LFOWaveform {
kTriangle, kSin, kRampUp, kRampDown,
kExpRampUp, kExpRampDn, kExpTriangle,
kSquare, kRSH, kPluck

Although the strongly typed enum has an underlying int datatype, it has to be specifically cast in order to make comparisons with it, so I have defined a macro to make that comparison:

// --- compare the waveform integer with the enum
if (parameters->waveformIndex == enumToInt(LFOWaveform::kSin))
// --- compare the VA filter type to BYPASS
if (parameters->filterIndex == enumToInt(VAFilterAlgorithm::kBypassFilter))

Regardless of how you implement the object (stand-alone or not) you get the parameter structure the same way. So, for each object you will also want to look at the custom parameter structure to see what values you can manipulate and what GUI controls you can present to the user.

  • all GUI parameters are tranmitted in their native ranges and types (i.e. not normalized); frequencies are in Hz and within the GUI ranges setup in the synthlabparams.h file
  • the four mod knob controls, customizable for each Core, transmit normalized values and there are helper functions to allow you to easily map those unipolar values on to linear, log, or anti-log ranges of other values
  • the first mod knob (MOD_KNOB_A) always defaults to the center value of 0.5; the other three default to 0.0
  • you should generally only use the custom parameter structure for GUI control manipulation, or for storing locally calculated (or cooked) parameters; do not use this structure for modulation, use the ModulationInput array instead
  • getParameter( ) always returns a shared pointer and you may adjust the values directly; there is NO setParameters( ) function as you are setting them directy

Here's the LFOParameter structure; each of these variable may map to a GUI control:

struct LFOParameters
int32_t waveformIndex = 0;
int32_t modeIndex = 0;
double frequency_Hz = 0.5;
double outputAmplitude = 1.0;
uint32_t quantize = 0;
double modKnobValue[4] = { 0.5, 0.0, 0.0, 0.0 };
uint32_t moduleIndex = 0;

In the tutorials that follow, we will generally use these parameter structures to initialize the objects and to send "fake" GUI control change values into the object; of course you will ultimately connect these parameters to your GUI controls.