Hey @daniel,
I’m not really confident that this is what you asked me but if I comment out this line the VST won’t crash on opening.
mLengthAttachment = new AudioProcessorValueTreeState::SliderAttachment(processor.getValueTreeState(), C74GenAudioProcessor::paramLength, *mLengthSlider);
The main problem I’m facing is that in the Cycling project you already got Parameters set up (relative to the gen-exported code) therefore some sort of ValueTree is already going, the one I added seems redundant (to my noobie eyes).
Furthermore there are a copule things that do seem strange to me like the absence of parameterChanged() (which I added, see below) and some stuff in getStateInformation()/getParameter()/setParameter(), which makes me think there are things I’m interferring with.
I’m pasting below all lines I added to files to get the AudioProcessorValueTreeState semi-working (based on your TapeDelay code):
In Processor.h
void parameterChanged(const String ¶meterID, float newValue) override;
AudioProcessorValueTreeState& getValueTreeState();
static String paramLength;
In Processor.cpp
mState = new AudioProcessorValueTreeState(*this, nullptr);
NormalisableRange<float> sliderRange(0.0f, 1.0f, 0.01f);
mState->createAndAddParameter(LENGTH_ID, LENGTH_NAME, LENGTH_NAME, sliderRange, 1.00f, nullptr, nullptr);
mState->addParameterListener(paramLength, this);
[...]
void C74GenAudioProcessor::parameterChanged(const String ¶meterID, float newValue)
{
if (parameterID == paramLength) {
mLength = newValue;
}
}
In Editor.h
ScopedPointer<Slider> mLengthSlider;
ScopedPointer<AudioProcessorValueTreeState::SliderAttachment> mLengthAttachment;
And in Editor.cpp
`mLengthAttachment = new AudioProcessorValueTreeState::SliderAttachment(processor.getValueTreeState(), C74GenAudioProcessor::paramLength, *mLengthSlider);`
As I said there are these lines already written in Processor.cpp:
void C74GenAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
char *state;
size_t statesize = C74_GENPLUGIN::getstatesize(m_C74PluginState);
state = (char *)malloc(sizeof(char) * statesize);
C74_GENPLUGIN::getstate(m_C74PluginState, state);
destData.replaceWith(state, sizeof(char) * statesize);
if (state) free(state);
}
I’m sure this is not the right way to format code, please correct me if I did something wrong.
Thank you for your time, I’m trying to figure something out but I literally can’t 