Range/AudioProcessorValueTreeState robustness


#1
void setUnnormalisedValue (float newUnnormalisedValue)
{
    if (value != newUnnormalisedValue)
    {
        const float newValue = range.convertTo0to1 (newUnnormalisedValue);
        setValueNotifyingHost (newValue);
    }
}

If newUnnormalizedValue < range.start then newValue can be NAN.

Then, in setValue below, newValue will remain as NAN even after snapToLegalValue.

This shouldn’t occur under normal circumstances, but as the values are being returned from the host and can’t be trusted maybe snapToLegalValue would be better if it handled NAN by returning a safe default.

void setValue (float newValue) override
{
    newValue = range.snapToLegalValue (range.convertFrom0to1 (newValue));

    if (value != newValue || listenersNeedCalling)
    {
        value = newValue;

        listeners.call (&AudioProcessorValueTreeState::Listener::parameterChanged, paramID, value);
        listenersNeedCalling = false;

        needsUpdate.set (1);
    }
}