Using parameters to change synthesiser voice values in a synth plugin

Not sure if this has been answered before. If so a link would be appreciated.

I have been developing a synthesiser plugin but have been unable to find a way of using a parameter value in my synthesiser voice class at runtime. I have tried pointers and running an update function from the audio processor to send the pointer values but no luck. I’m relatively new to coding audio processing software. Any ideas or solutions?

If you’re storing the parameters in a parent class of your SynthesiserVoice then you could have some getter methods for the parameters that you want in this class and pass a reference to it to your SynthesiserVoice. Then in your renderNextBlock() method you can update these parameters before rendering your voice.

Ed

1 Like

Ok good shout. I will have a look at this. I currently am creating variables of pointers to the parameter values which works in the main audio process block.

Cheers

I have been trying to get this working but had no luck. Are there and examples or sample code you could link me to?

I have been setting a variable in the synthesiserVoice renderNextBlock to a variable or pointer from the main AudioProcessor and this seems to only work when the voice is created and won’t update at runtime.

Like this:

void renderNextBlock{
valueInSynthVoice=*AudioProcessor::AudioProcessor().pointerInAudioProcessor;
processBlock(…)
}

Thanks

My Solution was this
class SynthesiserExt :public Synthesiser
{
public:
SynthesiserExt() :Synthesiser()
{

}
void handleParameter(const String & parameterID, float Value)
{
	const ScopedLock sl(lock);

	for (auto* voice : voices)
	{
		SynthesiserVoiceExt* synthesiserVoiceExt = dynamic_cast<SynthesiserVoiceExt*>(voice);
		if (synthesiserVoiceExt != nullptr)
		{
			synthesiserVoiceExt->parameterChanged(parameterID, Value);
		}
	}
}
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SynthesiserExt)

};

My Base Class for SynthesiserVoice:

class SynthesiserVoiceExt :public SynthesiserVoice
{
public:
SynthesiserVoiceExt():SynthesiserVoice()
{
}

virtual void parameterChanged(const String & parameterID, float Value) = 0;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SynthesiserVoiceExt)

};

in AudioProcessor I call:

void PluginProcessor::parameterChanged(const String & parameterID, float value)
{
if (parameterID == juce::String(PARAM_FmAmount1) )
{
_synthesizer.handleParameter(parameterID, value);
}
}

in my SynthVoice im Class which is derived from SynthesiserVoiceExt:

void SynthVoice::parameterChanged(const String & parameterID, float Value) override
{
// Set your local SynthVoice Members which you cann access during renderNextBlock
}

I hope that helps

1 Like