diff --git a/source/backend/plugin/DssiPlugin.cpp b/source/backend/plugin/DssiPlugin.cpp index ff661b778..2a68ecea7 100644 --- a/source/backend/plugin/DssiPlugin.cpp +++ b/source/backend/plugin/DssiPlugin.cpp @@ -471,6 +471,8 @@ public: const LADSPA_PortDescriptor portType = fDescriptor->PortDescriptors[i]; const LADSPA_PortRangeHint portRangeHints = fDescriptor->PortRangeHints[i]; + CARLA_ASSERT(fDescriptor->PortNames[i] != nullptr); + if (LADSPA_IS_PORT_AUDIO(portType)) { portName.clear(); @@ -948,7 +950,7 @@ public: if (kData->needsReset || ! kData->activeBefore) { - if (kData->event.portIn != nullptr) + if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) { for (unsigned char j=0, l=MAX_MIDI_CHANNELS; j < MAX_MIDI_CHANNELS; j++) { @@ -1181,7 +1183,7 @@ public: if (kData->midiprog.data[k].bank == nextBankId && kData->midiprog.data[k].program == nextProgramId) { setMidiProgram(k, false, false, false); - postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0); + postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0f); break; } } @@ -1192,7 +1194,10 @@ public: if (event.channel == kData->ctrlChannel) { if (! allNotesOffSent) + { sendMidiAllNotesOff(); + allNotesOffSent = true; + } if (fDescriptor->deactivate != nullptr) { @@ -1210,24 +1215,25 @@ public: fDescriptor->activate(fHandle2); } - postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0); - postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 1.0); - - allNotesOffSent = true; + postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0f); + postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 1.0f); } if (midiEventCount >= MAX_MIDI_EVENTS) continue; - carla_zeroStruct(fMidiEvents[midiEventCount]); + if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) + { + carla_zeroStruct(fMidiEvents[midiEventCount]); - fMidiEvents[midiEventCount].time.tick = sampleAccurate ? startTime : time; + fMidiEvents[midiEventCount].time.tick = sampleAccurate ? startTime : time; - fMidiEvents[midiEventCount].type = SND_SEQ_EVENT_CONTROLLER; - fMidiEvents[midiEventCount].data.control.channel = event.channel; - fMidiEvents[midiEventCount].data.control.param = MIDI_CONTROL_ALL_SOUND_OFF; + fMidiEvents[midiEventCount].type = SND_SEQ_EVENT_CONTROLLER; + fMidiEvents[midiEventCount].data.control.channel = event.channel; + fMidiEvents[midiEventCount].data.control.param = MIDI_CONTROL_ALL_SOUND_OFF; - midiEventCount += 1; + midiEventCount += 1; + } break; @@ -1235,23 +1241,27 @@ public: if (event.channel == kData->ctrlChannel) { if (! allNotesOffSent) + { + allNotesOffSent = true; sendMidiAllNotesOff(); - - allNotesOffSent = true; + } } if (midiEventCount >= MAX_MIDI_EVENTS) continue; - carla_zeroStruct(fMidiEvents[midiEventCount]); + if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) + { + carla_zeroStruct(fMidiEvents[midiEventCount]); - fMidiEvents[midiEventCount].time.tick = sampleAccurate ? startTime : time; + fMidiEvents[midiEventCount].time.tick = sampleAccurate ? startTime : time; - fMidiEvents[midiEventCount].type = SND_SEQ_EVENT_CONTROLLER; - fMidiEvents[midiEventCount].data.control.channel = event.channel; - fMidiEvents[midiEventCount].data.control.param = MIDI_CONTROL_ALL_NOTES_OFF; + fMidiEvents[midiEventCount].type = SND_SEQ_EVENT_CONTROLLER; + fMidiEvents[midiEventCount].data.control.channel = event.channel; + fMidiEvents[midiEventCount].data.control.param = MIDI_CONTROL_ALL_NOTES_OFF; - midiEventCount += 1; + midiEventCount += 1; + } break; } @@ -1285,7 +1295,7 @@ public: fMidiEvents[midiEventCount].data.note.channel = channel; fMidiEvents[midiEventCount].data.note.note = note; - postponeRtEvent(kPluginPostRtEventNoteOff, channel, note, 0.0); + postponeRtEvent(kPluginPostRtEventNoteOff, channel, note, 0.0f); } else if (MIDI_IS_STATUS_NOTE_ON(status)) { diff --git a/source/backend/plugin/FluidSynthPlugin.cpp b/source/backend/plugin/FluidSynthPlugin.cpp index 7b6be16be..0371f9271 100644 --- a/source/backend/plugin/FluidSynthPlugin.cpp +++ b/source/backend/plugin/FluidSynthPlugin.cpp @@ -886,15 +886,18 @@ public: if (kData->needsReset || ! kData->activeBefore) { - for (int c=0; c < MAX_MIDI_CHANNELS; c++) + if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) { + for (int c=0; c < MAX_MIDI_CHANNELS; c++) + { #ifdef FLUIDSYNTH_VERSION_NEW_API - fluid_synth_all_notes_off(fSynth, c); - fluid_synth_all_sounds_off(fSynth, c); + fluid_synth_all_notes_off(fSynth, c); + fluid_synth_all_sounds_off(fSynth, c); #else - fluid_synth_cc(f_synth, c, MIDI_CONTROL_ALL_SOUND_OFF, 0); - fluid_synth_cc(f_synth, c, MIDI_CONTROL_ALL_NOTES_OFF, 0); + fluid_synth_cc(f_synth, c, MIDI_CONTROL_ALL_SOUND_OFF, 0); + fluid_synth_cc(f_synth, c, MIDI_CONTROL_ALL_NOTES_OFF, 0); #endif + } } kData->needsReset = false; @@ -1079,7 +1082,7 @@ public: if (event.channel == kData->ctrlChannel) { setMidiProgram(k, false, false, false); - postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0); + postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0f); } else fluid_synth_program_select(fSynth, event.channel, fSynthId, bankId, progId); @@ -1094,18 +1097,22 @@ public: if (event.channel == kData->ctrlChannel) { if (! allNotesOffSent) + { + allNotesOffSent = true; sendMidiAllNotesOff(); + } - postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0); - postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 1.0); - - allNotesOffSent = true; + postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0f); + postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 1.0f); + if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) + { #ifdef FLUIDSYNTH_VERSION_NEW_API - fluid_synth_all_sounds_off(fSynth, event.channel); + fluid_synth_all_sounds_off(fSynth, event.channel); #else - fluid_synth_cc(f_synth, event.channel, MIDI_CONTROL_ALL_SOUND_OFF, 0); + fluid_synth_cc(f_synth, event.channel, MIDI_CONTROL_ALL_SOUND_OFF, 0); #endif + } } break; @@ -1113,15 +1120,19 @@ public: if (event.channel == kData->ctrlChannel) { if (! allNotesOffSent) + { + allNotesOffSent = true; sendMidiAllNotesOff(); + } - allNotesOffSent = true; - + if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) + { #ifdef FLUIDSYNTH_VERSION_NEW_API - fluid_synth_all_notes_off(fSynth, event.channel); + fluid_synth_all_notes_off(fSynth, event.channel); #else - fluid_synth_cc(f_synth, event.channel, MIDI_CONTROL_ALL_NOTES_OFF, 0); + fluid_synth_cc(f_synth, event.channel, MIDI_CONTROL_ALL_NOTES_OFF, 0); #endif + } } break; } @@ -1146,7 +1157,7 @@ public: fluid_synth_noteoff(fSynth, channel, note); - postponeRtEvent(kPluginPostRtEventNoteOff, channel, note, 0.0); + postponeRtEvent(kPluginPostRtEventNoteOff, channel, note, 0.0f); } else if (MIDI_IS_STATUS_NOTE_ON(status)) { diff --git a/source/backend/plugin/LadspaPlugin.cpp b/source/backend/plugin/LadspaPlugin.cpp index 3391ef4ab..180ac6a89 100644 --- a/source/backend/plugin/LadspaPlugin.cpp +++ b/source/backend/plugin/LadspaPlugin.cpp @@ -986,8 +986,8 @@ public: fDescriptor->activate(fHandle2); } - postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0); - postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 1.0); + postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0f); + postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 1.0f); } break; diff --git a/source/backend/plugin/LinuxSamplerPlugin.cpp b/source/backend/plugin/LinuxSamplerPlugin.cpp index df6ef1e81..3f7e0ddf4 100644 --- a/source/backend/plugin/LinuxSamplerPlugin.cpp +++ b/source/backend/plugin/LinuxSamplerPlugin.cpp @@ -472,7 +472,7 @@ public: if (kData->needsReset || ! kData->activeBefore) { - if (kData->event.portIn != nullptr) + if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) { for (k=0, i=MAX_MIDI_CHANNELS; k < MAX_MIDI_CHANNELS; k++) { @@ -670,7 +670,7 @@ public: if (kData->midiprog.data[k].bank == nextBankId && kData->midiprog.data[k].program == nextProgramId) { setMidiProgram(k, false, false, false); - postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0); + postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0f); break; } } @@ -681,18 +681,20 @@ public: if (event.channel == kData->ctrlChannel) { if (! allNotesOffSent) + { + allNotesOffSent = true; sendMidiAllNotesOff(); + } fAudioOutputDevice->Stop(); fAudioOutputDevice->Play(); - postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0); - postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 1.0); - - allNotesOffSent = true; + postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0f); + postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 1.0f); } - fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_SOUND_OFF, 0, k, sampleAccurate ? startTime : time); + if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) + fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_SOUND_OFF, 0, k, sampleAccurate ? startTime : time); break; @@ -700,12 +702,14 @@ public: if (event.channel == kData->ctrlChannel) { if (! allNotesOffSent) + { + allNotesOffSent = true; sendMidiAllNotesOff(); - - allNotesOffSent = true; + } } - fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_NOTES_OFF, 0, k, sampleAccurate ? startTime : time); + if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) + fMidiInputPort->DispatchControlChange(MIDI_CONTROL_ALL_NOTES_OFF, 0, k, sampleAccurate ? startTime : time); break; } @@ -732,7 +736,7 @@ public: fMidiInputPort->DispatchNoteOff(note, 0, channel, fragmentPos); - postponeRtEvent(kPluginPostRtEventNoteOff, channel, note, 0.0); + postponeRtEvent(kPluginPostRtEventNoteOff, channel, note, 0.0f); } else if (MIDI_IS_STATUS_NOTE_ON(status)) { diff --git a/source/backend/plugin/NativePlugin.cpp b/source/backend/plugin/NativePlugin.cpp index 1fbbc9f66..c1e25eca1 100644 --- a/source/backend/plugin/NativePlugin.cpp +++ b/source/backend/plugin/NativePlugin.cpp @@ -1061,9 +1061,9 @@ public: // -------------------------------------------------------------------------------------------------------- // Check if not active before - if (! kData->activeBefore) + if (kData->needsReset || ! kData->activeBefore) { - if (kData->event.portIn != nullptr) + if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) { for (k=0, i=MAX_MIDI_CHANNELS; k < MAX_MIDI_CHANNELS; k++) { @@ -1304,7 +1304,7 @@ public: if (kData->midiprog.data[k].bank == nextBankId && kData->midiprog.data[k].program == nextProgramId) { setMidiProgram(k, false, false, false); - postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0); + postponeRtEvent(kPluginPostRtEventMidiProgramChange, k, 0, 0.0f); break; } } @@ -1315,7 +1315,10 @@ public: if (event.channel == kData->ctrlChannel) { if (! allNotesOffSent) + { + allNotesOffSent = true; sendMidiAllNotesOff(); + } if (fDescriptor->deactivate != nullptr) { @@ -1333,22 +1336,23 @@ public: fDescriptor->activate(fHandle2); } - postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0); - postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 1.0); - - allNotesOffSent = true; + postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 0.0f); + postponeRtEvent(kPluginPostRtEventParameterChange, PARAMETER_ACTIVE, 0, 1.0f); } if (fMidiEventCount >= MAX_MIDI_EVENTS*2) continue; - fMidiEvents[fMidiEventCount].port = 0; - fMidiEvents[fMidiEventCount].time = sampleAccurate ? startTime : time; - fMidiEvents[fMidiEventCount].data[0] = MIDI_STATUS_CONTROL_CHANGE + event.channel; - fMidiEvents[fMidiEventCount].data[1] = MIDI_CONTROL_ALL_SOUND_OFF; - fMidiEvents[fMidiEventCount].data[2] = 0; + if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) + { + fMidiEvents[fMidiEventCount].port = 0; + fMidiEvents[fMidiEventCount].time = sampleAccurate ? startTime : time; + fMidiEvents[fMidiEventCount].data[0] = MIDI_STATUS_CONTROL_CHANGE + event.channel; + fMidiEvents[fMidiEventCount].data[1] = MIDI_CONTROL_ALL_SOUND_OFF; + fMidiEvents[fMidiEventCount].data[2] = 0; - fMidiEventCount += 1; + fMidiEventCount += 1; + } break; @@ -1356,21 +1360,25 @@ public: if (event.channel == kData->ctrlChannel) { if (! allNotesOffSent) + { + allNotesOffSent = true; sendMidiAllNotesOff(); - - allNotesOffSent = true; + } } if (fMidiEventCount >= MAX_MIDI_EVENTS*2) continue; - fMidiEvents[fMidiEventCount].port = 0; - fMidiEvents[fMidiEventCount].time = sampleAccurate ? startTime : time; - fMidiEvents[fMidiEventCount].data[0] = MIDI_STATUS_CONTROL_CHANGE + event.channel; - fMidiEvents[fMidiEventCount].data[1] = MIDI_CONTROL_ALL_NOTES_OFF; - fMidiEvents[fMidiEventCount].data[2] = 0; + if (fOptions & PLUGIN_OPTION_SEND_ALL_SOUND_OFF) + { + fMidiEvents[fMidiEventCount].port = 0; + fMidiEvents[fMidiEventCount].time = sampleAccurate ? startTime : time; + fMidiEvents[fMidiEventCount].data[0] = MIDI_STATUS_CONTROL_CHANGE + event.channel; + fMidiEvents[fMidiEventCount].data[1] = MIDI_CONTROL_ALL_NOTES_OFF; + fMidiEvents[fMidiEventCount].data[2] = 0; - fMidiEventCount += 1; + fMidiEventCount += 1; + } break; } @@ -1413,7 +1421,7 @@ public: if (status == MIDI_STATUS_NOTE_ON) postponeRtEvent(kPluginPostRtEventNoteOn, channel, midiEvent.data[1], midiEvent.data[2]); else if (status == MIDI_STATUS_NOTE_OFF) - postponeRtEvent(kPluginPostRtEventNoteOff, channel, midiEvent.data[1], 0.0); + postponeRtEvent(kPluginPostRtEventNoteOff, channel, midiEvent.data[1], 0.0f); break; } diff --git a/source/backend/plugin/VstPlugin.cpp b/source/backend/plugin/VstPlugin.cpp index a095f358f..e12e84d94 100644 --- a/source/backend/plugin/VstPlugin.cpp +++ b/source/backend/plugin/VstPlugin.cpp @@ -97,6 +97,8 @@ public: dispatcher(effStopProcess, 0, 0, nullptr, 0.0f); dispatcher(effMainsChanged, 0, 0, nullptr, 0.0f); dispatcher(effClose, 0, 0, nullptr, 0.0f); + + fEffect = nullptr; } // -------------------------------------------------------------------