Saturday 11 May 2013

The setParameter Function

Look through 'PluginProcessor.ccp' until you find a bit that looks like this:
void GainPluginAudioProcessor::setParameter (int index, float newValue)
{
}
When the host calls this function is is asking to set a specific parameter to a specific value.

There are two things we need to note about this function. Firstly the return type 'void'. This means that the function won't actually return a value. The host is just telling the plug-in to change a parameter value, it does not require anything in return.

Next is that we have two input arguments, an integer called 'index' and a float called 'newValue'. The first argument is the index of the parameter being set (like the argument to getParameter). The second is the value to set the parameter to.

Once again we can ignore the 'index' argument as we only have one parameter. We need to pay attention to the 'newValue' argument though as we need to store it in our parameter variable.

We will change to code to this:
void GainPluginAudioProcessor::setParameter (int index, float newValue)
{
    gain = newValue;
}
All we are doing here is take the value given as an input argument, 'newValue', and storing it in our 'gain' variable. Save these changes to your project and we can move to the next step.

Now our host is able to:
  • Ask the plug-in how many parameters it has.
  • Get the names of those parameters.
  • Get the values of those parameters.
  • Set the value of those parameters.
There are only a couple more things we need to do before we have a working plug-in.

Have a nice day now!
Sean

No comments:

Post a Comment