There is a long term issue with the interface from Faust to create JUCE plugins. The Faust code FaustPlugInAudioParameterFloat inherits from juce::AudioParameterFloat and overrides the setValue() function as follows:
virtual void setValue (float newValue) override
{
modifyZone(FAUSTFLOAT(range.convertFrom0to1(newValue)));
}
This results in the “base” AudioParameterFloat setValue() never being called and the value in the base class never being updated.
This causes the value tree to be unable to record the correct values and as a result when the editor window is closed and re-opened, it has the incorrect values.
The Faust plugin works just fine, it never really uses the “value” durring processing, only the UI uses it when restoring the state on a close/re-open.
It is not possible using the “stock” JUCE classes to call the setValue() on the base class, it is private.
Moving setValue() from private to public in AudioParameterFloat() and calling it in the setValue() of FaustPlugInAudioParameterFloat() solves the problem:
virtual void setValue (float newValue) override
{
modifyZone(FAUSTFLOAT(range.convertFrom0to1(newValue)));
// Needs to update Value in RangedParameter
AudioParameterFloat::setValue(newValue);
}
This requires a change to JUCE that I hope is not needed. Is there a better way to do this?
Here is the full FaustPlugInAudioParameterFloat class (with call to public setValue()):
struct FaustPlugInAudioParameterFloat : public juce::AudioParameterFloat, public uiOwnedItem {
FaustPlugInAudioParameterFloat(GUI* gui, FAUSTFLOAT* zone, const std::string& path, const std::string& label, FAUSTFLOAT init, FAUSTFLOAT min, FAUSTFLOAT max, FAUSTFLOAT step)
:juce::AudioParameterFloat(juce::ParameterID(path, /* versionHint */ 1), label, float(min), float(max), float(init)), uiOwnedItem(gui, zone)
{}
virtual ~FaustPlugInAudioParameterFloat() {}
void reflectZone() override
{
FAUSTFLOAT v = *fZone;
fCache = v;
if (v >= range.start && v <= range.end) {
setValueNotifyingHost(range.convertTo0to1(float(v)));
}
}
virtual void setValue (float newValue) override
{
modifyZone(FAUSTFLOAT(range.convertFrom0to1(newValue)));
// Needs to update Value in RangedParameter
AudioParameterFloat::setValue(newValue);
}
