AudioParameterFloat parameter change notification


#1

There is absolute no way to detect a parameter change in this class, also setValue() is private.
(The demos are using some timer-based approach in GenericEditor, which isn’t very cool if you have hundreds of parameters)

Please move setValue to public, so someone can do this

virtual void setValue(float newValue) override
{
	AudioParameterFloat::setValue(newValue);
	// do stuff to handle parameter change
};

Or, if this is not an option, please add a virtual callback

public:
	virtual void valueChanged() {};

private:

	void AudioParameterFloat::setValue(float newValue)
	{
		value = range.convertFrom0to1(newValue);
		valueChanged()
	};

#2

OK I’ve added a valueChanged callback to the parameter classes on develop with commit 544d328.


#3

A useful addition to that could be to check if the value actually changed:

void AudioParameterFloat::setValue (float newValue)                      
{ 
    auto unnormalised = range.convertFrom0to1 (newValue); 
    if (value != unnormalised)
    {
        value = unnormalised;
        valueChanged (get()); 
    }
}

(edited variable hiding)


#4

Cool, second newValue should be renamed :wink:

Btw: in the meantime i returned to AudioProcessorParameterWithID because I prefer storing the parameter as normalized value for various reasons (mostly get/set integrity)


#5

Ah, silly me :wink:
I’ll edit that…