From f89da1834caaf320bf48041ba4d425a98114f40a Mon Sep 17 00:00:00 2001 From: Alex Birch Date: Tue, 27 Feb 2018 23:33:19 +0000 Subject: [PATCH] audio plugin host appears to invoke initialise twice. use singleton fluidsynth model now to survive that. also, clear midi output to make VST3 stop complaining --- Source/FluidSynthModel.cpp | 4 ++++ Source/PluginProcessor.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Source/FluidSynthModel.cpp b/Source/FluidSynthModel.cpp index bab6c34..a64b2df 100644 --- a/Source/FluidSynthModel.cpp +++ b/Source/FluidSynthModel.cpp @@ -20,6 +20,10 @@ FluidSynthModel::~FluidSynthModel() { } void FluidSynthModel::initialise() { + if (initialised) { + delete_fluid_synth(synth); + delete_fluid_settings(settings); + } settings = new_fluid_settings(); // https://sourceforge.net/p/fluidsynth/wiki/FluidSettings/ fluid_settings_setstr(settings, "synth.verbose", "yes"); diff --git a/Source/PluginProcessor.cpp b/Source/PluginProcessor.cpp index 63fe898..5e37aae 100644 --- a/Source/PluginProcessor.cpp +++ b/Source/PluginProcessor.cpp @@ -152,6 +152,10 @@ void JuicySFAudioProcessor::processBlock (AudioBuffer& buffer, MidiBuffer synth.renderNextBlock (buffer, midiMessages, 0, numSamples); fluid_synth_process(fluidSynth, numSamples, 1, nullptr, buffer.getNumChannels(), buffer.getArrayOfWritePointers()); + // (see juce_VST3_Wrapper.cpp for the assertion this would trip otherwise) + // we are !JucePlugin_ProducesMidiOutput, so clear remaining MIDI messages from our buffer + midiMessages.clear(); + // In case we have more outputs than inputs, this code clears any output // channels that didn't contain input data, (because these aren't // guaranteed to be empty - they may contain garbage).