What's the deal with Bluetooth MIDI on Windows?
Recently, I purchased a Bluetooth LE MIDI device (Korg Microkey Air).
On the product page, it's not clear if you need to manually install drivers, or what. Turns out, it works out of the box, but there's a catch: Windows "supports" BLE LE MIDI, but only through their new UWP MIDI (WinRT) interface.
Anyway, the solution is annoying but not very complicated, you need to route the UWP MIDI to the old Win32 MIDI API in order to use it in programs that don't support the new MIDI API (Reaper, for example).
There are some products on the Microsoft store that do this (not free). Instead, I wrote a little tray tool to do this: https://github.com/TesseractCat/UWP-Midi-Adapter. It works in concert with another piece of software, loopMIDI, which creates virtual MIDI ports. There are some other tools on Github which do the same thing.
Since midir, the Rust MIDI library I'm using supports both Win32 and UWP MIDI, all I have to do is relay all the messages, like so:
let midi_in = MidiInput::new("uwp-shim in").unwrap();
let midi_out = MidiOutput::new("uwp-shim out").unwrap();
if let Some(in_port) = midi_in.find_port_by_id(self.in_id.clone().unwrap()) {
println!("Found in port...");
if let Some(out_port) = midi_out.find_port_by_id(self.out_id.clone().unwrap()) {
println!("Found out port...");
if let Ok(mut midi_out_conn) = midi_out.connect(&out_port, "uwp-shim out") {
println!("Made out connection...");
match midi_in.connect(&in_port, "uwp-shim in", move |_, message, _| {
let _ = midi_out_conn.send(message);
}, ()) {
Ok(midi_in_conn) => {
println!("Relay formed!");
self.midi_in = Some(midi_in_conn);
},
Err(e) => println!("Got error {e}")
}
}
}
}
If you're curious, the Bluetooth MIDI latency isn't that bad. At the very least, your audio latency is a lot more important. I'm pretty sure the bluetooth latency is still slightly noticeable though.
It's a shame that this is the best solution at the moment, but overall it's not so bad. Hopefully this helps if you are thinking about purchasing a bluetooth MIDI keyboard for use with a Windows computer.