Ok, I just took the Juce Plugin example, clean, and just added a Graph and tested with Live, and it crashes. Here’s detailed info about what happens:
Startup Live, here I used the Demonstration version 8.0.9 with a 30 day full saving licensing, which is free. I added Juce Test plugin, all good, saved the live scene, started a new scene, loaded up the previous
scene and it crashed.
So its simple to reproduce the problem: create a new project, add the Juce Test alone, nothing else, save, re-load, crash.
Now, here’s what I did in the Juce Plugin VST example. (Windows 32 bits XP 2)
[code]void DemoJuceFilter::prepareToPlay (double sampleRate, int samplesPerBlock)
{
// do your pre-playback setup stuff here…
graph.setPlayConfigDetails (getNumInputChannels(), getNumOutputChannels(), sampleRate, samplesPerBlock);
graph.prepareToPlay (sampleRate, samplesPerBlock);
keyboardState.reset();
}[/code]
[code]void DemoJuceFilter::releaseResources()
{
// when playback stops, you can use this as an opportunity to free up any
// spare memory, etc.
graph.releaseResources();
}[/code]
[code]void DemoJuceFilter::processBlock (AudioSampleBuffer& buffer,
MidiBuffer& midiMessages)
{
// for each of our input channels, we’ll attenuate its level by the
// amount that our volume parameter is set to.
for (int channel = 0; channel < getNumInputChannels(); ++channel)
{
buffer.applyGain (channel, 0, buffer.getNumSamples(), gain);
}
// in case we have more outputs than inputs, we'll clear any output
// channels that didn't contain input data, (because these aren't
// guaranteed to be empty - they may contain garbage).
for (int i = getNumInputChannels(); i < getNumOutputChannels(); ++i)
{
buffer.clear (i, 0, buffer.getNumSamples());
}
// if any midi messages come in, use them to update the keyboard state object. This
// object sends notification to the UI component about key up/down changes
keyboardState.processNextMidiBuffer (midiMessages,
0, buffer.getNumSamples(),
true);
// have a go at getting the current time from the host, and if it's changed, tell
// our UI to update itself.
AudioPlayHead::CurrentPositionInfo pos;
if (getPlayHead() != 0 && getPlayHead()->getCurrentPosition (pos))
{
if (memcmp (&pos, &lastPosInfo, sizeof (pos)) != 0)
{
lastPosInfo = pos;
sendChangeMessage (this);
}
}
else
{
zeromem (&lastPosInfo, sizeof (lastPosInfo));
lastPosInfo.timeSigNumerator = 4;
lastPosInfo.timeSigDenominator = 4;
lastPosInfo.bpm = 120;
}
graph.processBlock(buffer,midiMessages);
}[/code]
And in the headers file, of course, I added “AudioProcessorGraph graph;”
That’s pretty much it.
So, what I’m doing wrong?
The code above works on all other hosts but LIVE.