ParameterAttachment::resetToDefaultValue()

The current and only possible way to reset a parameter to it’s default value is like this:

auto* freqParam = apvts->getParameter(...);
auto defaultValue = freqParam->getDefaultValue(); //this is a normalized value
freqParamAttachment.setValueAsCompleteGesture( freqParam->convertFrom0to1(defaultValue);

This is annoying because:

  • AudioProcessorParameter::getDefaultValue() returns a normalized value
  • ParameterAttachment::setValueAsCompleteGesture() wants a De-normalized value
  • ParameterAttachment::setValueAsCompleteGesture() internally normalizes the de-normalized value that is passed in.

All that needs to be added is:

void ParameterAttachment::resetToDefaultValue()
{
    beginGesture();
    parameter.setValueNotifyingHost(parameter.getDefaultValue());
    endGesture();
}

I am currently using Component::mouseDoubleClick as the way that I tell the parameter to reset to the default value.