SynthLab SDK
Updating GUI Parameters

If you are using the SynthEngine, you update the GUI parameters by first requesting a shared pointer to the engine's parameter structure, which will contain parameters relevant to the engine level of operation. It also contains a shared pointer to the voice parameter structure. You use these two pointers directly to update all of the engine, voice and module parameters. Notice that this is part of SynthLab's shared parameter paradigm that was baked into the design from the very beginning. If you don't like it, you may freely replace it with another scheme for sharing these parameters while still retaining the code for decoding MIDI and rendering note events from voices.

In my implementations, the ASPiK framework's processing object declares and stores these two pointers - they are guaranteed to never change during the life of the engine because my processing object (PluginCore) insantiates one and only one engine object for the life of the plugin. However, they may also be obtained on-the-fly during each GUI update phase depending on your coding preference.

// --- the engine
std::shared_ptr<SynthLab::SynthEngine> synthEngine = nullptr; // < instantiated in constuctor
// --- for GUI parameter updating
std::shared_ptr<SynthLab::SynthEngineParameters> engineParameters = nullptr;
std::shared_ptr<SynthLab::SynthVoiceParameters> voiceParameters = nullptr;
// --- during initialization/instantiation of framework's processing object
//
// --- get the engine parameters
synthEngine->getParameters(engineParameters);
// --- get the voice parameters from the engine parameters
voiceParameters = engineParameters->voiceParameters;
//

With the two shared pointers in hand, you can update all of the bits and pieces of the synth, with all redundant data being shared across all identical objects. For example, it your engine has 16 voice objects in its array, and each includes an LFO named LFO1, then the LFO GUI parameters (rate, waveform, output amplitude, etc...) are common to all LFO1s in the voices. The shared parameter pointers allow access to them at once without copying pointers or copying parameter data. Here are some code fragmements showing various GUI updating for the example synths. Of course these GUI variables would be coming from your impelmentation and would likely not have the same names, so I replaced my variable names with raw numbers as examples only.

Engine Parameters

// ---
engineParameters->globalPitchBendSensCoarse = 12; // --- semitones
engineParameters->globalTuningCoarse = -8.750; // --- semitones
engineParameters->globalUnisonDetune_Cents = 10.0; // --- detuning spread in unison mode
engineParameters->globalVolume_dB = -6.00; // -- native dB
//

Voice Parameters

// ---
voiceParameters->glideTime_mSec = 1000.0; // glide time from GUI
voiceParameters->filterModeIndex = 1; // 1 = parallel filters
//

SynthModule Parameters shared via the voice parameter struct

// --- LFO 1
voiceParameters->lfo1Parameters->frequency_Hz = 0.25;
voiceParameters->lfo1Parameters->outputAmplitude = 0.707; // not dB
// filter EG
voiceParameters->filterEGParameters->attackTime_mSec = 20.0;
voiceParameters->filterEGParameters->decayTime_mSec = 250.0;
voiceParameters->filterEGParameters->sustainLevel = 0.8;
voiceParameters->filterEGParameters->releaseTime_mSec = 2000.0;
// --- oscillator output amplitudes for four member oscillators
voiceParameters->osc1Parameters->outputAmplitude_dB = 0.0;
voiceParameters->osc2Parameters->outputAmplitude_dB = +3.5;
voiceParameters->osc3Parameters->outputAmplitude_dB = 0.0;
voiceParameters->osc4Parameters->outputAmplitude_dB = -12.0;
// --- DCA
voiceParameters->dcaParameters->ampEGIntensity = 1.0;
//

ModMatrix Parameters shared via the voice parameter struct
The Modulation Matrix object's parameter structure also contains both variables and functions to allow matrix manipulation from your GUI code. These functions take modulation array index values, shown as constants here and defined in synthconstants.h for the example synths. The functions allow setting the intensity controls and enabling/disabling particular modulation routings. Here are some code fragmements showing mod matrix parameter function calls from the example synths, this time they show my GUI variable names. You access the modMatrixParameters via the voiceParameters:

voiceParameters->modMatrixParameters

// --- Source Intensities (could also do destination or channel intensities
// All intensity controls are on the range [-1, +1] to allow for inversion
// of the modulation
modMatrixParameters->setMM_SourceIntensity(SynthLab::kSourceLFO1_Norm, /* LFO1 source array index */
lfo1SourceInt); /* source intensity from GUI */
modMatrixParameters->setMM_SourceIntensity(SynthLab::kSourceLFO2_Norm, /* LFO2 source array index */
lfo2SourceInt); /* source intensity from GUI */
modMatrixParameters->setMM_SourceIntensity(SynthLab::kSourceFilterEG_Norm, /* Filter source array index */
filterEGSourceInt); /* source intensity from GUI */
modMatrixParameters->setMM_SourceIntensity(SynthLab::kSourceAuxEG_Norm, /* Aux EG source array index */
auxEGSourceInt); /* source intensity from GUI */
modMatrixParameters->setMM_SourceIntensity(SynthLab::kSourceAuxEG_Bias, /* Aux EG source array index */
auxEGBiasedSourceInt); /* source intensity from GUI */
// --- enable/disable mod routings from LFO1 to filter1's bipolar fc
modMatrixParameters->setMM_ChannelEnable(SynthLab::kSourceLFO1_Norm, /* mod source array index */
SynthLab::kDestFilter1_fc_Bipolar, /* mod dest array index */
enableLFO1Filter1fc); /* true/false to enable/disable */
modMatrixParameters->setMM_ChannelEnable(SynthLab::kSourceLFO1_Norm, /* mod source array index */
SynthLab::kDestFilter2_fc_Bipolar, /* mod dest array index */
enableLFO1Filter2fc); /* true/false to enable/disable */
//

Here are some things to remember and think about:

  • once all updates are complete, you call the setParameters( ) method on the engine object
  • note that the majority of your parameter adjustments occured when you wrote into the parameter member variables, directly changing their values via a smart pointer
  • the engine's setParameters() function mainly addresses engine level functionality, such as unison detuning of various voices when the user selects unison mode and makes alterations to the voice parameter's global variables
  • the SynthModules in the voice will be updating during the render cycle as with the standalone objects; remember that their parameter structures are shared and given to them at instantiation time


    synthlab_4.png