Using BlueALSA as BLE MIDI server - arkq/bluez-alsa GitHub Wiki
[!IMPORTANT] This document refers to BlueALSA components by the names used in the latest sources. For release v4.3.1 or earlier please note that the
bluealsad
daemon was calledbluealsa
.
Introduction
It is possible to use BlueALSA as a BLE-MIDI server. For that, the bluez-alsa
project must be configured with the --enable-midi
option. This will enable
ALSA sequencer integration within the BlueALSA system service.
Running BlueALSA as a BLE-MIDI server
To run BlueALSA as a BLE-MIDI server, the BlueALSA service must be started
with Bluetooth LE MIDI profile enabled. Optionally, one can also enable
Bluetooth LE advertisement for the MIDI service. Otherwise, LE advertisement
has to be configured externally, e.g. with bluetoothctl
. The disadvantage
of using the built-in LE advertisement is that it is not possible turn it off
without restarting the BlueALSA service (which will also disconnect BLE-MIDI
clients).
bluealsad -p midi --midi-advertisement
This will create software MIDI input/output port which can be used as any other
ALSA MIDI port. The MIDI port will be named BLE MIDI Server
.
pi@rpi:~ $ aseqdump -l
Port Client name Port name
0:0 System Timer
0:1 System Announce
128:0 BlueALSA BLE MIDI Server
Connecting to the BLE-MIDI server
Once the BlueALSA service is running, the BLE-MIDI client can connect to the
server. However, in order to connect to the BLE-MIDI profile, the client must
be paired with the server. By default, pairing process requires PIN code
authentication. So, before connecting to the BLE-MIDI server, one has to run
PIN code authentication application, or simply start bluetoothctl
and wait
for the pairing request.
Exemplary use cases
Using BLE-MIDI server with MIDI keyboard
Connect MIDI keyboard to the host and connect its MIDI output to the
BLE MIDI Server
port. With such configuration, the MIDI keyboard will be able
to send MIDI messages to connected BLE-MIDI client.
-
Connect the MIDI keyboard to the host.
-
Connect the MIDI keyboard output to the
BLE MIDI Server
port.aconnect <MIDI keyboard> <BLE MIDI Server>
E.g.:
pi@rpi:~ $ aconnect -l client 24: 'Digital Piano' [type=kernel,card=2] 0 'Digital Piano MIDI 1' client 128: 'BlueALSA' [type=user,pid=314] 0 'BLE MIDI Server ' pi@rpi:~ $ aconnect 24:0 128:0 pi@rpi:~ $ aconnect -l client 24: 'Digital Piano' [type=kernel,card=2] 0 'Digital Piano MIDI 1' Connecting To: 128:0 client 128: 'BlueALSA' [type=user,pid=314] 0 'BLE MIDI Server ' Connected From: 24:0
Using BLE-MIDI server with MIDI software synthesizer
Install software synthesizer, e.g. timidity
, and run it as a service. Then
connect BLE MIDI Server
port with the synthesizer input port.
-
Install
timidity
system service.sudo apt install timidity-daemon
-
Connect the
BLE MIDI Server
port with thetimidity
input port.pi@rpi:~ $ aconnect -l client 128: 'BlueALSA' [type=user,pid=314] 0 'BLE MIDI Server ' client 129: 'TiMidity' [type=user,pid=315] 0 'TiMidity port 0 ' 1 'TiMidity port 1 ' 2 'TiMidity port 2 ' 3 'TiMidity port 3 ' pi@rpi:~ $ aconnect 128:0 129:0 pi@rpi:~ $ aconnect -l client 128: 'BlueALSA' [type=user,pid=314] 0 'BLE MIDI Server ' Connecting To: 129:0 client 129: 'TiMidity' [type=user,pid=315] 0 'TiMidity port 0 ' Connected From: 128:0 1 'TiMidity port 1 ' 2 'TiMidity port 2 ' 3 'TiMidity port 3 '