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

This commit is contained in:
Alex Birch 2018-02-27 23:33:19 +00:00
parent c129ce78a0
commit f89da1834c
No known key found for this signature in database
GPG Key ID: 305EB1F98D44ACBA
2 changed files with 8 additions and 0 deletions

View File

@ -20,6 +20,10 @@ FluidSynthModel::~FluidSynthModel() {
} }
void FluidSynthModel::initialise() { void FluidSynthModel::initialise() {
if (initialised) {
delete_fluid_synth(synth);
delete_fluid_settings(settings);
}
settings = new_fluid_settings(); settings = new_fluid_settings();
// https://sourceforge.net/p/fluidsynth/wiki/FluidSettings/ // https://sourceforge.net/p/fluidsynth/wiki/FluidSettings/
fluid_settings_setstr(settings, "synth.verbose", "yes"); fluid_settings_setstr(settings, "synth.verbose", "yes");

View File

@ -152,6 +152,10 @@ void JuicySFAudioProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer
synth.renderNextBlock (buffer, midiMessages, 0, numSamples); synth.renderNextBlock (buffer, midiMessages, 0, numSamples);
fluid_synth_process(fluidSynth, numSamples, 1, nullptr, buffer.getNumChannels(), buffer.getArrayOfWritePointers()); 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 // In case we have more outputs than inputs, this code clears any output
// channels that didn't contain input data, (because these aren't // channels that didn't contain input data, (because these aren't
// guaranteed to be empty - they may contain garbage). // guaranteed to be empty - they may contain garbage).