Hi all
Relatively new to all of this so I fully expect, and will not be offended by, your derision and scorn.
I have developed an audio plugin with about 60 parameters, and I have used the same method as the Juce Demo plugin for adding parameters. I now want to implement a preset system, as well as undo and redo functionality. After browsing the forum for a while it appears that using an AudioProcessorValueTreeState would be the best way to accomplish this.
I experimented with this by taking one of my previous parameters and trying to reimplement it in the following way:
In PluginProcessor.h i declare the following (all public for the time being):
AudioProcessorParameter* inputGain;
UndoManager undoManager;
AudioProcessorValueTreeState pluginState;
In PluginProcessor.cpp I initialise the AudioProcessorValueTreeState and attempt to create a parameter in the following way:
PluginProcessor::PluginProcessor()
:undoManager(30000, 30),
pluginState(*this, &undoManager)
{
NormalisableRange<float> dbScale(-60.f, 6.f);
inputGain = pluginState.createAndAddParameter ("inputGain", "InputGain", "Input Gain",
dbScale, 0.f, nullptr, nullptr);
}
In my PluginEditor.h I declare a slider and slider attachment:
ScopedPointer<Slider> inputGainSlider;
ScopedPointer<AudioProcessorValueTreeState::SliderAttachment> inputGainSliderAttachment;
And in PluginEditor.cpp:
addAndMakeVisible(inputGainSlider = new Slider());
inputGainSliderAttachment = new AudioProcessorValueTreeState::SliderAttachment(owner.pluginState,
"inputGain", *inputGainSlider);
After building this, it crashes my DAW (64-bit Ableton Live, Windows) as soon as I try and open the plugin. Upon further testing, even removing all the above code from my PluginEditor, removing the undoManager and simply creating and initialising my AudioProcessorValueTreeState:
PluginProcessor::PluginProcessor()
: pluginState(*this, nullptr)
{
}
without creating and attaching any parameters results in my DAW crashing as soon as the plugin is loaded.
I reckon I am probably misunderstanding something basic and fundamental, so if anyone can name and shame what I have done please do so.
Further questions:
- Is an AudioProcessorValueTreeState the best way of implementing a preset and undo/redo system?
- Are there any preferable solutions, or could anyone point me in a different direction?
- (probably a separate issue…) I am using similar subclasses for sliders etc as is done in the JUCE Demo plugin, ie. ParameterSlider. My understanding is that the timerCallback() and updateSliderPos() functions are there to enable the GUI to respond to host automation, however when I test this using my plugin and the JUCE Demo plugin, neither of them can respond to automation while their GUI is open - instead they disable the host automation as soon as the first parameter change happens (again, this is using 64-bit Ableton Live in Windows - and again, it’s very possible I am the one misunderstanding or doing something incorrectly).
Any help or information would be greatly appreciated.
P.S I have booked my flight and ticket to the ADC in November, and am looking forward to meeting and learning from many of you there!