MIDI over Bluetooth Low Energy on Linux finally accepted

I am very happy to say that MIDI over BLE on Linux will be part of the next BlueZ release! You can check both commits for this initial release.

In order to build you need alsa-lib dependency and run ./configure  with --enable-midi  option because it is disabled by default since it is an experimental feature yet.

Now you can run bluetoothd and just connect to a BLE device that advertises the MIDI Primary Service. Once done that, bluetoothd will load the MIDI driver and a new ALSA Sequencer client/port will be created for the device. You can check with aseqdump -l  command to list all available ports for subscription. Connect to your Synth and enjoy!

Okay, there might be one caveat on this whole thing. It is very important that Connection Interval property is set via the Connection Update Command from the peripheral, but some devices don’t do it! This is required by the BLE-MIDI spec, but apparently MacOS or iOS force a Connection Interval for their particular adapters on each platform when connected to a MIDI device (yes, clearly they don’t trust device manufactures and they now exactly the most optimal configuration for their specific adapters). And since most MIDI device users use those OSes, they don’t really care about setting the Connection Interval. That’s a shame, I know…

So, If you notice any drop of connection, bad latency and packet drops, force BlueZ do the same – enforce a Connection Interval. To do that you have to edit a file that is located in  /var/lib/bluetooth/[ADAPTER]/[DEVICE]/info  where [ADAPTER] and [DEVICE] is their respective addresses and restart bluetoothd. Add the following lines:

If these values doesn’t work well for you, you might need to try out different MinInterval and MaxInterval for your particular adapter. I know it sucks, but that’s the price to pay for non compliant devices. If that is the case, complain to the manufacturer!

Anyway, back to the good stuff.

There is still work to be done. It is missing the Peripheral role support that can be implemented as a bluetoothd plugin or, perhaps, as a dedicated program if the prior doesn’t meet the low-latency requirements. There is also a support missing in ALSA Sequencer for arbitrary event timestamp, which is required by BLE-MIDI.

I will continue maintaining my personal branch of BlueZ to support MIDI further developments, so feel free to drop a line there, open issues (or use BlueZ bugtracker), send pull-requets etc.

Thanks to ROLI Ltd. for supporting me on this project. Also, Ben Supper, Luiz Augusto von Dentz and Adam Goode for reviewing the patch set.

  • chookass

    Great work! Thanks a lot! I jus got my hand on an ACPAD and hope it will help.
    However I’m a little kind of lost about the procedure to use in order to install…
    You said
    «In order to build you need alsa-lib dependency and run
    ./configure with
    –enable-midi option because it is disabled by default since it is an experimental feature yet.»

    where is this configure script? Do we need to get bluez from your
    specific fork?? (i understood not)… Would you please mind be provide
    clear instruction about how to install this plugin? Thanks a lot!

    • Felipe Tonello


      You have to download the development version of BlueZ, and compile it.

      Since it is a development version yet, it is very technical procedure to do it. So, unless you know what you are doing, I don’t recommend it.

      But anyway, download the git repository with git clone git://git.kernel.org/pub/scm/bluetooth/bluez.git --depth=1 then run ./bootstrap and ./configure --enable-midi commands as mentioned. You will probably need to install some libraries in order to compile it. Run make to compile when configuration is ready.

      When done run the bluetooth daemon you just built as root (example sudo ./src/bluetoothd -d -n), but make sure you don’t have any other instances of the bluetoothd daemon running.

      • chookass

        thanks a lot ! now I understood, it was the development version you were talking about! =) I will manage it >=]