Many of my AU soft synth's knobs have ranges outside of 0 - 1. For example my Delay Spread knob goes from 0 to 100. Automation expects values within 0 - 1 so I:
Convert to 0 - 1 in my custom slider class:
double MySlider::getValue()
{
float currentValue = Slider::getValue();
float convertedValue = fabs((currentValue - getMinimum()) / (getMaximum() - getMinimum()));
return convertedValue;
}
Send in the value:
void SynthComponent::sliderValueChanged (Slider* sliderThatWasMoved)
{
MySlider* tmpSlider = static_cast<MySlider*>(sliderThatWasMoved);
int thisID = tmpSlider->getID();
PrImerAudioProcessor* pAProc = static_cast <PrimerAudioProcessor*> (pluginEditor->getAudioProcessor());
float newValue = tmpSlider->getValue();
pAProc->setParameterNotifyingHost(thisID, newValue);
}
Convert it back to its original range and do any secondary changes in setParameter before sending it into my synth:
void PrimerAudioProcessor::setParameter (int index, float newValue)
{
// convert it back to original range
float reconvertedValue = newValue * fabs(Par::controlRanges[index][1] - Par::controlRanges[index][0]) + Par::controlRanges[index][0];
if (index == DELAYSPREADR)
{
// tweak it one more time into a value the synth expects
reconvertedValue = reconvertedValue / 1000.0;
}
else if //// do other conversions for other controls....
synth.addToParList(index, reconvertedValue);
}
This works out fine EXCEPT when using touch automation. For some odd reason that second tweak:
reconvertedValue = reconvertedValue / 1000.0;
actually shows up in the automation! So when I leave it in, the automation barely moves off of 0, because it's showing tiny values. If I delete it, the automation works perfectly, showing values from 0 - 1, but the synth of course isn't getting the values it expects.
Why would the automation be effected by what I do in setParameter? Isn't setParameterNotifiyingHost responsible for effecting automation?
FYI - my beginParameterChangeGesture is in the custom slider's startedDragging() method, and endParameterChangeGesture is in the Slider's stoppedDraggin() method. I've tested this on Mac in both Logic and Live.
