Thanks - that was my erroneous assumption on how it should work based on not having an example of multiple parameters.
I have searched and I can only find one example in class AUv3SynthProcessor .h:
AUv3SynthProcessor : public AudioProcessor
{
public:
AUv3SynthProcessor ()
: AudioProcessor (BusesProperties().withOutput ("Output", AudioChannelSet::stereo(), true)),
currentRecording (1, 1), currentProgram (0)
{
// initialize parameters
addParameter (isRecordingParam = new AudioParameterBool ("isRecording", "Is Recording", false));
addParameter (roomSizeParam = new AudioParameterFloat ("roomSize", "Room Size", 0.0f, 1.0f, 0.5f));
[…]
//==============================================================================
void getStateInformation (MemoryBlock& destData) override
{
MemoryOutputStream stream (destData, true);
stream.writeFloat (*isRecordingParam);
stream.writeFloat (*roomSizeParam);
}
void setStateInformation (const void* data, int sizeInBytes) override
{
MemoryInputStream stream (data, static_cast<size_t> (sizeInBytes), false);
isRecordingParam->setValueNotifyingHost (stream.readFloat());
roomSizeParam->setValueNotifyingHost (stream.readFloat());
}
private:
[…]
AudioParameterBool* isRecordingParam;
AudioParameterFloat* roomSizeParam;
What this shows is that, although two parameters are declared and added as a Bool and a Float, they are both written and read as Floats. Is that correct?
Anyway, I tried it both ways in my plugin and it still doesn’t work:
Reading/writing as different types:
[…]
{
addParameter (speed = new AudioParameterFloat ("speed", "Arpeggiator Speed", 0.0, 1.0, 0.5));
addParameter (transpose = new AudioParameterInt ("transpose", "Arpeggiator Transpose", -12, 12, 0));
}
[…]
//==============================================================================
void getStateInformation (MemoryBlock& destData) override
{
MemoryOutputStream stream (destData, true);
stream.writeFloat (*speed);
stream.writeInt (*transpose);
}
void setStateInformation (const void* data, int sizeInBytes) override
{
MemoryInputStream stream (data, static_cast<size_t> (sizeInBytes), false);
speed->setValueNotifyingHost (stream.readFloat());
transpose->setValueNotifyingHost (stream.readInt());
}
private:
//==============================================================================
AudioParameterFloat* speed;
AudioParameterInt* transpose;
Reading/Writing as Floats:
[…]
{
addParameter (speed = new AudioParameterFloat ("speed", "Arpeggiator Speed", 0.0, 1.0, 0.5));
addParameter (transpose = new AudioParameterInt ("transpose", "Arpeggiator Transpose", -12, 12, 0));
}
[…]
//==============================================================================
void getStateInformation (MemoryBlock& destData) override
{
MemoryOutputStream stream (destData, true);
stream.writeFloat (*speed);
stream.writeFloat (*transpose);
}
void setStateInformation (const void* data, int sizeInBytes) override
{
MemoryInputStream stream (data, static_cast<size_t> (sizeInBytes), false);
speed->setValueNotifyingHost (stream.readFloat());
transpose->setValueNotifyingHost (stream.readFloat());
}
private:
//==============================================================================
AudioParameterFloat* speed;
AudioParameterInt* transpose;
Neither of these work correctly. When saving and opening a preset in the AudioPluginHost, The speed value is restored correctly, the transpose value is not.
I understand there may be better ways of handling multiple parameters such as XML or ValueTree, but I’m proceeding step by step with the tutorials and would like to understand this, first. Thanks!