diff --git a/ktmidi-ci-tool/src/commonMain/kotlin/dev/atsushieno/ktmidi/citool/MidiDeviceManager.kt b/ktmidi-ci-tool/src/commonMain/kotlin/dev/atsushieno/ktmidi/citool/MidiDeviceManager.kt index 0250e0319..d2b8f6ecd 100644 --- a/ktmidi-ci-tool/src/commonMain/kotlin/dev/atsushieno/ktmidi/citool/MidiDeviceManager.kt +++ b/ktmidi-ci-tool/src/commonMain/kotlin/dev/atsushieno/ktmidi/citool/MidiDeviceManager.kt @@ -58,9 +58,11 @@ class MidiDeviceManager { midiProtocol = MidiTransportProtocol.UMP, ) - virtualMidiInput2 = midiAccessValue.createVirtualOutputReceiver(pcOut2) - midiInputOpened.forEach { it(virtualMidiInput2!!) } - virtualMidiOutput2 = midiAccessValue.createVirtualInputSender(pcIn2) + if (midiAccessValue.canCreateVirtualPort(pcIn2) && midiAccessValue.canCreateVirtualPort(pcOut2)) { + virtualMidiInput2 = midiAccessValue.createVirtualOutputReceiver(pcOut2) + midiInputOpened.forEach { it(virtualMidiInput2!!) } + virtualMidiOutput2 = midiAccessValue.createVirtualInputSender(pcIn2) + } } catch (ex: Exception) { println(ex) ex.printStackTrace() diff --git a/ktmidi-ci-tool/src/desktopMain/kotlin/main.kt b/ktmidi-ci-tool/src/desktopMain/kotlin/main.kt index 24de67fe9..7e830ad0f 100644 --- a/ktmidi-ci-tool/src/desktopMain/kotlin/main.kt +++ b/ktmidi-ci-tool/src/desktopMain/kotlin/main.kt @@ -12,19 +12,14 @@ import java.io.File fun main(args: Array) = application { initializeAppModel(this) AppModel.midiDeviceManager.midiAccess = - /* if (File("/dev/snd/seq").exists()) AlsaMidiAccess() else if (args.contains("jvm")) JvmMidiAccess() else if (System.getProperty("os.name").contains("Windows")) JvmMidiAccess() - else RtMidiAccess() // rtmidi-javacpp does not support Windows build nowadays. - */ - LibreMidiAccess.create(MidiTransportProtocol.MIDI1) - /* - MergedMidiAccess("LibreMidi1+2", listOf( + // else RtMidiAccess() + else MergedMidiAccess("LibreMidiAccess-1+2", listOf( LibreMidiAccess.create(MidiTransportProtocol.UMP), LibreMidiAccess.create(MidiTransportProtocol.MIDI1) )) - */ Window(onCloseRequest = ::exitApplication, state = rememberWindowState(), title = "midi-ci-tool") {