Hi all, I’ve used to initialize / setup the AudioProcessorValueTreeState in an other class or method. Something like this:
MyAudioProcessor:: MyAudioProcessor() :
apvts(*this, &undoManager_) {
setup();
}
void MyAudioProcessor::setup() {
AudioProcessorValueTreeStateBuilder::initialize(apvts, this);
}
However with the new initialization I need to do something like this:
MyAudioProcessor:: MyAudioProcessor() :
apvts(*this, &undoManager_, "PARAMETERS", ParameterLayoutBuilder::Build()) {
}
Where ParameterLayoutBuilder::Build() create a vector of std::vector<std::unique_ptr<RangedAudioParameter>>.
But now I was wondering if there will be an elegant solution to add a listener to all the parameters of the ParameterLayout. Indeed from what I understand I cannot add the listener into the ParameterLayoutBuilder::Build() because the AudioProcessorValueTreeState is not instanciate at this moment. I cannot do something like this:
MyAudioProcessor:: MyAudioProcessor() :
apvts(*this, &undoManager_, "PARAMETERS", ParameterLayoutBuilder::Build(apvts, this)) {
}
The only solution I found is to do something like:
MyAudioProcessor:: MyAudioProcessor() :
parameterLayoutBuilder,
apvts(*this, &undoManager_, "PARAMETERS", parameterLayoutBuilder.build()) {
for (auto& parameterId : parameterLayoutBuilder.getParameterIds() ) {
parameters.addParameterListener(parametersId, this);
}
}
I’ve now a member for the parameterLayoutBuilder object and use it to build the parameters and to get the list of the parameter IDs. But I need to solve some pitfalls when I create the vector of unique_ptr in the parameterLayoutBuilder to store the parameter IDs.
Wouldn’t be an other better and more elegant solution to create an AudioProcessorValueTreeState and listen to its parameters?