Host Friendly Parameters?


Which function/s are the ones the host calls where my values have to map to a range of 0 to 1, is it only getParameter? and also is setParameter the only functions where the host returns a number in the range of 0-1 that needs to be transformed to my appropriate range?


yes, just those. Which others are you worried about?


Not really worried just curious, getParameter is also being called from the editorcomponent like below

[code]// take a local copy of the info we need while we’ve got the lock…
const AudioFilterBase::CurrentPositionInfo positionInfo (filter->lastPosInfo);
const float newGain = filter->getParameter (0);

// ..release the lock ASAP

// ..and after releasing the lock, we're free to do the time-consuming UI stuff..
String infoText;
infoText << String (positionInfo.bpm, 2) << T(" bpm, ")
         << positionInfo.timeSigNumerator << T("/") << positionInfo.timeSigDenominator
         << T("  -  ") << timeToTimecodeString (positionInfo.timeInSeconds) 
         << T("  -  ") << ppqToBarsBeatsString (positionInfo.ppqPosition,

if (positionInfo.isPlaying)
    infoText << T("  (playing)");

infoLabel->setText (infoText, false);

/* Update our slider.

   (note that it's important here to tell the slider not to send a change 
   message, because that would cause it to call the filter with a parameter 
   change message again, and the values would drift out.
gainSlider->setValue (newGain, false);[/code]

When the editor calls getParameter from the filter this will return the transformed value between 0-1(As I have to transform my range for the host), and later its setting the gainSlider value with this, does that mean I have to re-transform this value here to my range for the slider? In the demo its ok, as gain is already between 0-1 but what if it wasn’t


Well yes, if you’re using a slider with a different range, your UI code would have to transform it to be 0-1.0 when it sets/gets the value from the plugin.


in my current implementation, i’ve extended the AudioFilterBase to let it manipulate parameter objects on its own.
i’ve added getParameterReal and setParameterReal in order to let the coder use/set whatever mapping range he needs in UI. It will be the underlying parameter manager that will translate the value forth and back 0…1 <> min…max as we need.

actually i find more simpler to define parameters to have some ranges once, then build UI controls based on those parameter ranges, and manipulate them like i don’t even know the host needs 0…1 (but if you really need to have it in that 0…1 for some specific purpose, you can use it the same)…