(I’m very new to this so please pardon my ignorance)
I’m trying to follow along with this tutorial:
And I’m having trouble getting the Audio ProcessorValueTreeState to actually work. It seems like a few things he’s using have been deprecated, in particular:
The attachment classes are not deprecated, ScopedPointer is. Use std::unique_ptr instead.
The errors you’re seeing could be a number of things, you’ll have to be more specific. Which errors, on which platform?
The current way of creating parameters is passing a ParameterLayout to APVTS’ constructor. This usually involves having a free function that returns a ParameterLayout. The layout is filled with unique_ptrs containing each of your parameters, so your function may return a braced list with calls to std::make_unique:
Alternatively, you could create a vector, add your parameters there, then return the begin/end iterators:
juce::AudioProcessorValueTreeState::ParameterLayout createParameters()
{
std::vector<std::unique_ptr<juce::RangedAudioParameter>> parameters;
parameters.reserve (/* nr of parameters */);
parameters.push_back (std::make_unique<juce::AudioParameterFloat> (/***/));
/* or */
parameters.emplace_back (new juce::AudioParameterFloat (/***/));
/* etc */
return { parameters.begin(), parameters.end() };
}
Then in your processor:
class MyAudioProcessor : juce::AudioProcessor
{
juce::UndoManager undoManager; // if you're using one
juce::AudioProcessorValueTreeState apvts{ *this, &undoManager, "my plugin",
createParameters() };
/* etc */
}
Because this is all quite verbose, instead of a free function I use a function object with some helpers, so the code that actually adds the parameters gets a little more concise.
I seem to be getting these errors on even brand new projects now (using xcode):
/Users/mbarbara/JUCE/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h
/Users/mbarbara/JUCE/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h:45:53 Unknown type name 'StringFro'
/Users/mbarbara/JUCE/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h:45:74 Expected ')'
/Users/mbarbara/JUCE/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h:45:118 No member named 'attributes' in 'juce::AudioProcessorValueTreeStateParameterAttributes'
/Users/mbarbara/JUCE/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h:45:130 Use of undeclared identifier 'attributes'
/Users/mbarbara/JUCE/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h:45:181 Use of undeclared identifier 'x'
/Users/mbarbara/JUCE/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h:47:19 Expected member name or ';' after declaration specifiers
/Users/mbarbara/JUCE/modules/juce_audio_processors/utilities/juce_AudioProcessorValueTreeState.h:500:76 No member named 'withLabel' in 'juce::AudioProcessorValueTreeStateParameterAttributes'
Did I break JUCE or something?
As for the rest of it, I’m going to try and wrap my head around that over the next day or so and poke you if I have any questions.
I seem to have resolved the errors by re-installing JUCE. I don’t quite understand why the following code is giving me an “error, no overloaded ‘=’” error though.
.cpp:
filterCutoffValue = new juce::AudioProcessorValueTreeState::SliderAttachment (audioProcessor.tree, "cutoff", mCutoffDial);
filterResValue = new juce::AudioProcessorValueTreeState::SliderAttachment (audioProcessor.tree, "resonance", mResdial);
filterMenuChoice = new juce::AudioProcessorValueTreeState::ComboBoxAttachment (audioProcessor.tree, "filterMenu", mFilterMenu)
There’s no implicit conversion to std::unique_ptr<T> from T* (a plain pointer, which is the return of new). That constructor (2) is marked explicit, precisely to avoid this kind of thing. You have these alternatives: