From e61466a7f749387204421a4d62ba98e0d025cbce Mon Sep 17 00:00:00 2001 From: Wei Shuyu Date: Wed, 31 Jul 2024 02:29:45 +0800 Subject: [PATCH] Create virtual port on supported platform Create virtual port on MAC/Linux when hardware port not available --- src/midi_rtmidi.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/midi_rtmidi.cpp b/src/midi_rtmidi.cpp index d16036b..768ed1c 100644 --- a/src/midi_rtmidi.cpp +++ b/src/midi_rtmidi.cpp @@ -36,9 +36,16 @@ int MIDI_Init(int port) unsigned count = s_midi_in->getPortCount(); + if (count == 0) { printf("No midi input\n"); + auto current_api = s_midi_in->getCurrentApi(); + if (current_api == RtMidi::LINUX_ALSA || current_api == RtMidi::UNIX_JACK || current_api == RtMidi::MACOSX_CORE) { + printf("creating a virtual port\n"); + s_midi_in->openVirtualPort("Nuked SC55"); + return 1; + } delete s_midi_in; s_midi_in = nullptr; return 0;