From 5360ba000074f0ff1692c55445921588b836a53f Mon Sep 17 00:00:00 2001 From: "Attila M. Magyar" Date: Sun, 30 Jun 2024 13:11:53 +0200 Subject: [PATCH 1/4] VST3: store kAfterTouch events with the correct size ...otherwise MidiBuffer::push_back() will drop them. --- libs/ardour/vst3_plugin.cc | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libs/ardour/vst3_plugin.cc b/libs/ardour/vst3_plugin.cc index d688902d3b..238ccf4870 100644 --- a/libs/ardour/vst3_plugin.cc +++ b/libs/ardour/vst3_plugin.cc @@ -647,36 +647,44 @@ VST3PI::vst3_to_midi_buffers (BufferSet& bufs, ChanMapping const& out_map) data[2] = vst_to_midi (e.polyPressure.pressure); mb.push_back (e.sampleOffset, Evoral::MIDI_EVENT, 3, data); break; - case Vst::Event::kLegacyMIDICCOutEvent: + case Vst::Event::kLegacyMIDICCOutEvent: { + size_t size = 0; + switch (e.midiCCOut.controlNumber) { case Vst::kCtrlPolyPressure: + size = 3; data[0] = MIDI_CMD_NOTE_PRESSURE | e.midiCCOut.channel; data[1] = e.midiCCOut.value; data[2] = e.midiCCOut.value2; break; default: /* Control Change */ + size = 3; data[0] = MIDI_CMD_CONTROL | e.midiCCOut.channel; data[1] = e.midiCCOut.controlNumber; data[2] = e.midiCCOut.value; break; case Vst::kCtrlProgramChange: + size = 2; data[0] = MIDI_CMD_PGM_CHANGE | e.midiCCOut.channel; data[1] = e.midiCCOut.value; data[2] = e.midiCCOut.value2; break; case Vst::kAfterTouch: + size = 2; data[0] = MIDI_CMD_CHANNEL_PRESSURE | e.midiCCOut.channel; data[1] = e.midiCCOut.value; data[2] = e.midiCCOut.value2; break; case Vst::kPitchBend: + size = 3; data[0] = MIDI_CMD_BENDER | e.midiCCOut.channel; data[1] = e.midiCCOut.value; data[2] = e.midiCCOut.value2; break; } - mb.push_back (e.sampleOffset, Evoral::MIDI_EVENT, e.midiCCOut.controlNumber == Vst::kCtrlProgramChange ? 2 : 3, data); + mb.push_back (e.sampleOffset, Evoral::MIDI_EVENT, size, data); break; + } case Vst::Event::kNoteExpressionValueEvent: case Vst::Event::kNoteExpressionTextEvent: From e1ef129ab0605cb24b32c5c6be02699c36da2929 Mon Sep 17 00:00:00 2001 From: "Attila M. Magyar" Date: Sun, 30 Jun 2024 13:29:58 +0200 Subject: [PATCH 2/4] VST2: store VstMidiEvents with the correct size ...otherwise MidiBuffer::push_back() will drop them. (E.g. MIDI_CMD_CHANNEL_PRESSURE events are just 2 bytes, not 3.) --- libs/ardour/session_vst.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libs/ardour/session_vst.cc b/libs/ardour/session_vst.cc index d82ebf9003..b44c4a5ad6 100644 --- a/libs/ardour/session_vst.cc +++ b/libs/ardour/session_vst.cc @@ -27,6 +27,8 @@ #endif #include +#include "evoral/midi_util.h" + #include "ardour/audioengine.h" #include "ardour/debug.h" #include "ardour/session.h" @@ -301,7 +303,12 @@ intptr_t Session::vst_callback ( for (int n = 0 ; n < v->numEvents; ++n) { VstMidiEvent *vme = (VstMidiEvent*) (v->events[n]->dump); if (vme->type == kVstMidiType) { - plug->midi_buffer()->push_back(vme->deltaSamples, Evoral::MIDI_EVENT, 3, (uint8_t*)vme->midiData); + plug->midi_buffer()->push_back( + vme->deltaSamples, + Evoral::MIDI_EVENT, + Evoral::midi_event_size((uint8_t)vme->midiData[0]), + (uint8_t*)vme->midiData + ); } } } From 630587ee3f59ebe98ccd9dcd015c4a20677b6f7a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 30 Jun 2024 23:07:29 +0200 Subject: [PATCH 3/4] VST2: amend prev commit, ignore SysEx and invalid MIDI events --- libs/ardour/session_vst.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/ardour/session_vst.cc b/libs/ardour/session_vst.cc index b44c4a5ad6..2374ccf4d9 100644 --- a/libs/ardour/session_vst.cc +++ b/libs/ardour/session_vst.cc @@ -302,11 +302,12 @@ intptr_t Session::vst_callback ( VstEvents* v = (VstEvents*)ptr; for (int n = 0 ; n < v->numEvents; ++n) { VstMidiEvent *vme = (VstMidiEvent*) (v->events[n]->dump); - if (vme->type == kVstMidiType) { + int size = Evoral::midi_event_size((uint8_t)vme->midiData[0]); + if (vme->type == kVstMidiType && size > 0) { plug->midi_buffer()->push_back( vme->deltaSamples, Evoral::MIDI_EVENT, - Evoral::midi_event_size((uint8_t)vme->midiData[0]), + size, (uint8_t*)vme->midiData ); } From dd4abedb8c5f2352104e6afac0ef0fcc14a75c66 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 1 Jul 2024 11:36:01 -0600 Subject: [PATCH 4/4] add to Kurzweil K2700 MIDNAM --- share/patchfiles/Kurzweil_K2700.midnam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/patchfiles/Kurzweil_K2700.midnam b/share/patchfiles/Kurzweil_K2700.midnam index e10787e033..6c50554dfd 100644 --- a/share/patchfiles/Kurzweil_K2700.midnam +++ b/share/patchfiles/Kurzweil_K2700.midnam @@ -1,7 +1,7 @@ - + Nikolaos Strikos strikosn@gmail.com Kurzweil K2700