Topic: Bluetooth MIDI on Raspberry Pi 4

Hello,

I am seeking for help here.
I have a Raspberry Pi 4 on which Pianoteq7 is properly installed.
The Raspberry Ubuntu has bluetooth and is able to connect the my Roland keyboard.
However the keyboard is not visible in Pianoteq settings, there is no "Bluetooth MIDI" button in the Linux version of Pianoteq7… is that a missing feature?


thanks for your help!

Re: Bluetooth MIDI on Raspberry Pi 4

Jeremie wrote:

Hello,

I am seeking for help here.
I have a Raspberry Pi 4 on which Pianoteq7 is properly installed.
The Raspberry Ubuntu has bluetooth and is able to connect the my Roland keyboard.
However the keyboard is not visible in Pianoteq settings, there is no "Bluetooth MIDI" button in the Linux version of Pianoteq7… is that a missing feature?

I'm pretty sure Bluetooth Midi is a feature that would be automatically supported by Pianoteq, if a connection in fact exists.  Are you certain that your Linux install has support for Bluetooth MIDI, not just Bluetooth audio?  To check, you could try running the command 'aconnect -l' and see if it lists your keyboard as a connected midi device.

Re: Bluetooth MIDI on Raspberry Pi 4

If the keyboard is connected to the Raspberry over Bluetooth then it should just work in Pianoteq. I have a MIDI device sending output to Pianoteq with no configuration other than making a Bluetooth connection. I am though using the Blueman Applet: https://manpages.ubuntu.com/manpages/xe...let.1.html
but I don't know if that makes any difference - I needed it because the MIDI controller uses Bluetooth LE.

Re: Bluetooth MIDI on Raspberry Pi 4

hesitz wrote:

I'm pretty sure Bluetooth Midi is a feature that would be automatically supported by Pianoteq, if a connection in fact exists.  Are you certain that your Linux install has support for Bluetooth MIDI, not just Bluetooth audio?  To check, you could try running the command 'aconnect -l' and see if it lists your keyboard as a connected midi device.


Yes I am sure it is Bluetooth MIDI not Audio.
I tried 'aconnect _l' and this is the output i get:

client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'

and when Pianoteq7 is open the same command gives:

client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
    Connecting To: 128:0
client 128: 'Pianoteq STAGE' [type=user,pid=5048]
    0 'Midi Through Port-0'
    Connected From: 14:0

not sure how to analyze these outputs

Re: Bluetooth MIDI on Raspberry Pi 4

Jeremie wrote:
hesitz wrote:

I'm pretty sure Bluetooth Midi is a feature that would be automatically supported by Pianoteq, if a connection in fact exists.  Are you certain that your Linux install has support for Bluetooth MIDI, not just Bluetooth audio?  To check, you could try running the command 'aconnect -l' and see if it lists your keyboard as a connected midi device.


Yes I am sure it is Bluetooth MIDI not Audio.
I tried 'aconnect _l' and this is the output i get:

client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'

and when Pianoteq7 is open the same command gives:

client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
    Connecting To: 128:0
client 128: 'Pianoteq STAGE' [type=user,pid=5048]
    0 'Midi Through Port-0'
    Connected From: 14:0

not sure how to analyze these outputs

There is no midi connection with your keyboard.  It would be listed as a client if it existed.  I don't know what your problem is, but I'm pretty sure whatever you did has not created a bluetooth midi connection.  It sounds like you do have a bluetooth connection, and your OS may support bluetooth midi, but why are you certain you have a bluetooth midi connection rather than a bluetooth audio connection?    I would check into using something like the blueman applet mentioned in post above to create the bluetooth midi connection.

Last edited by hesitz (14-05-2022 17:24)

Re: Bluetooth MIDI on Raspberry Pi 4

After a lot of research I came to the conclusion that Bluetooth MIDI is not enabled by default on Ubuntu; it is a specif configuration of BlueZ that has to be done manually. It is fairly complex but this post (even though a bit outdated) helped:
https://mclarenlabs.com/blog/2019/01/15...pberry-pi/

now I have mi bluetooth MIDI keyboard connected:

~$ aconnect -l
client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
client 128: 'FP-30X MIDI' [type=user,pid=1065]
    0 'FP-30X MIDI Bluetooth'

But it is still not working in Pianoteq7 nor when I test with the 'aseqdump' command:

~$ aseqdump -p 128:0
Waiting for data. Press Ctrl+C to end.
Source  Event                  Ch  Data

... there is no data coming though when I play the keyboard.

Again, any help would be much appreciated

Re: Bluetooth MIDI on Raspberry Pi 4

Jeremie wrote:

After a lot of research I came to the conclusion that Bluetooth MIDI is not enabled by default on Ubuntu; it is a specif configuration of BlueZ that has to be done manually. It is fairly complex but this post (even though a bit outdated) helped:
https://mclarenlabs.com/blog/2019/01/15...pberry-pi/

now I have mi bluetooth MIDI keyboard connected:

~$ aconnect -l
client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
client 128: 'FP-30X MIDI' [type=user,pid=1065]
    0 'FP-30X MIDI Bluetooth'

But it is still not working in Pianoteq7 nor when I test with the 'aseqdump' command:

~$ aseqdump -p 128:0
Waiting for data. Press Ctrl+C to end.
Source  Event                  Ch  Data

... there is no data coming though when I play the keyboard.

Again, any help would be much appreciated

The 'aconnect -l' command should list both the FP-30X and Pianoteq7 as clients.  If it doesn't show them as connected, they're not connected. 

user  'ean' above said "I have a MIDI device sending output to Pianoteq with no configuration other than making a Bluetooth connection."  So I assume you're really close to having it working.

What does Pianoteq7 show under 'Active Midi Inputs' when you look at its midi options page?  Make sure you're looking at this at the same time as aconnect -l shows FP30x and Pianoteq7 as clients.  If making no progress, maybe test the order that you're doing things.  Create the bluetooth midi connection before you start Pianoteq7, or vice versa.   Test things after a fresh restart, etc.  I think you're almost there.

Last edited by hesitz (14-05-2022 17:56)

Re: Bluetooth MIDI on Raspberry Pi 4

The 'aconnect -l' command should list both the FP-30X and Pianoteq7 as clients.  If it doesn't show them as connected, they're not connected. 

user  'ean' above said "I have a MIDI device sending output to Pianoteq with no configuration other than making a Bluetooth connection."  So I assume you're really close to having it working.

What does Pianoteq7 show under 'Active Midi Inputs' when you look at its midi options page?  Make sure you're looking at this at the same time as aconnect -l shows FP30x and Pianoteq7 as clients.  If making no progress, maybe test the order that you're doing things.  Create the bluetooth midi connection before you start Pianoteq7, or vice versa.   Test things after a fresh restart, etc.  I think you're almost there.

When I launch Pianoteq7 The connection between both happens indeed (and I can see it in the UI of Pianoteq too):


~$ aconnect -l
client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
client 128: 'FP-30X MIDI' [type=user,pid=1065]
    0 'FP-30X MIDI Bluetooth'
    Connecting To: 129:1
client 129: 'Pianoteq STAGE' [type=user,pid=7214]
    1 'FP-30X MIDI Bluetooth'
    Connected From: 128:0

Unfortunately, playing the piano triggers no input in Pianoteq... the notes are not played, no input, no sound at all

Re: Bluetooth MIDI on Raspberry Pi 4

Jeremie wrote:

The 'aconnect -l' command should list both the FP-30X and Pianoteq7 as clients.  If it doesn't show them as connected, they're not connected. 

user  'ean' above said "I have a MIDI device sending output to Pianoteq with no configuration other than making a Bluetooth connection."  So I assume you're really close to having it working.

What does Pianoteq7 show under 'Active Midi Inputs' when you look at its midi options page?  Make sure you're looking at this at the same time as aconnect -l shows FP30x and Pianoteq7 as clients.  If making no progress, maybe test the order that you're doing things.  Create the bluetooth midi connection before you start Pianoteq7, or vice versa.   Test things after a fresh restart, etc.  I think you're almost there.

When I launch Pianoteq7 The connection between both happens indeed (and I can see it in the UI of Pianoteq too):


~$ aconnect -l
client 0: 'System' [type=kernel]
    0 'Timer           '
    1 'Announce        '
client 14: 'Midi Through' [type=kernel]
    0 'Midi Through Port-0'
client 128: 'FP-30X MIDI' [type=user,pid=1065]
    0 'FP-30X MIDI Bluetooth'
    Connecting To: 129:1
client 129: 'Pianoteq STAGE' [type=user,pid=7214]
    1 'FP-30X MIDI Bluetooth'
    Connected From: 128:0

Unfortunately, playing the piano triggers no input in Pianoteq... the notes are not played, no input, no sound at all

I can only think of a couple things to check.

First, view the 'Midi' tab in Pianoteq options.  The window in upper left monitors any midi messages that are received.  When you have a connection and play the keyboard, do you see any messages showing up there?  If you see messages appear, then it's possible the midi part is working fine, but that Pianoteq isn't connecting its audio output properly.  In this case you would want to go to the 'Devices' tab and click 'Test' button to check whether the audio output is actually working.

Second, on the 'Devices' tab what shows up in the 'Active Midi Inputs' box?  And what items have checkmarks to the left of them.  One of the items should be something like 'FP-30x Bluetooth'.  It may be checked with a grayed out box if you have 'Listen to all midi inputs' checked.  If so, maybe try unclicking 'Listen to all inputs' and put a check on the 'FP-30x Bluetooth entry manually, listen just to that input.

Last edited by hesitz (14-05-2022 22:42)

Re: Bluetooth MIDI on Raspberry Pi 4

hesitz wrote:

First, view the 'Midi' tab in Pianoteq options.  The window in upper left monitors any midi messages that are received.  When you have a connection and play the keyboard, do you see any messages showing up there?  If you see messages appear, then it's possible the midi part is working fine, but that Pianoteq isn't connecting its audio output properly.  In this case you would want to go to the 'Devices' tab and click 'Test' button to check whether the audio output is actually working.

Second, on the 'Devices' tab what shows up in the 'Active Midi Inputs' box?  And what items have checkmarks to the left of them.  One of the items should be something like 'FP-30x Bluetooth'.  It may be checked with a grayed out box if you have 'Listen to all midi inputs' checked.  If so, maybe try unclicking 'Listen to all inputs' and put a check on the 'FP-30x Bluetooth entry manually, listen just to that input.

I think it boils down to software and/or hardware issues with my Raspberry Pi 4.
- I can see both Audio and MIDI Devices of the Roland FP-30X in the Bluetooth menu of Ubuntu
- I pair and connect the MIDI one
- The command 'aconnect -l' shows me properly the 'FP-30X MIDI Bluetooth' as 'client 128'
- In Pianoteq the 'FP-30X MIDI Bluetooth' is there too and the only MIDI Input connected, the Audio output works properly when clicking the 'Test' button

So all seems perfectly fine... except that nothing happens when I play the Roland FP-30X keyboard.

I read somewhere on a forum that it may be a problem with the Bluetooth chip of the Raspberry Pi itself that would not properly support MIDI input... He solved it with an external Bluetooth USB dongle; maybe I should try that too...

Re: Bluetooth MIDI on Raspberry Pi 4

I would forget Pianoteq for the moment, just use aseqdump to look for the input after doing aseqdump -l to get the list of devices.
I'm using a Pi400 so don't know if that makes a difference.

Re: Bluetooth MIDI on Raspberry Pi 4

ean wrote:

I would forget Pianoteq for the moment, just use aseqdump to look for the input after doing aseqdump -l to get the list of devices.
I'm using a Pi400 so don't know if that makes a difference.

aseqdump -l
Port    Client name                      Port name
  0:0    System                           Timer
  0:1    System                           Announce
14:0    Midi Through                     Midi Through Port-0
128:0    FP-30X MIDI                      FP-30X MIDI Bluetooth

it looks like it's there

Re: Bluetooth MIDI on Raspberry Pi 4

Jeremie wrote:
hesitz wrote:

First, view the 'Midi' tab in Pianoteq options.  The window in upper left monitors any midi messages that are received.  When you have a connection and play the keyboard, do you see any messages showing up there?  If you see messages appear, then it's possible the midi part is working fine, but that Pianoteq isn't connecting its audio output properly.  In this case you would want to go to the 'Devices' tab and click 'Test' button to check whether the audio output is actually working.

Second, on the 'Devices' tab what shows up in the 'Active Midi Inputs' box?  And what items have checkmarks to the left of them.  One of the items should be something like 'FP-30x Bluetooth'.  It may be checked with a grayed out box if you have 'Listen to all midi inputs' checked.  If so, maybe try unclicking 'Listen to all inputs' and put a check on the 'FP-30x Bluetooth entry manually, listen just to that input.


So all seems perfectly fine... except that nothing happens when I play the Roland FP-30X keyboard.

I read somewhere on a forum that it may be a problem with the Bluetooth chip of the Raspberry Pi itself that would not properly support MIDI input... He solved it with an external Bluetooth USB dongle; maybe I should try that too...

I'd be very skeptical of concluding that the Pi hardware has some problem with Bluetooth MIDI, there's lots of resources around that show people getting Bluetooth MIDI working on RPi's, and I know a guy who has done it.  It tended to be somewhat of a problem because most Pi distros don't come with Bluetooth MIDI support, you need to recompile the bluez package to get it.  But apparently your Ubuntu supports it with just some reconfiguration.

At this point I would go back a step and make sure that you're able to get a working MIDI connection using a USB cable.  Have you done this already?

EDIT: Whoops, going back to your older posts I see the McLarenLabs link is actually about recompiling bluez, not mere reconfiguration.  So, no, there was not technically any built-in Bluetooth Midi support in your Ubuntu distro.  You had to recompile to get it, same as with other distros on the Pi that don't come with Bluetooth Midi.  FWIW, I tried same recompile process for Bluez a couple years ago and never got it to work, though I ended up not being able to solve a problem with the recompile, gave up and started using RT-MIDI for a bit for a wireless connection to my PC, not really an option with keyboard controller to Pi solution.  If I recall correctly my problems with recompiling Bluez probably came from not using most recent version, or having to use part from an older version of the bluez package, or maybe something with dependencies installed.  Things got screwed up enough I just gave up and haven't tried again since.

When you recompiled the bluez package did everything go **exactly** as written on that MclarenLabs page.  What version of bluez did you have before the recompile, and what version did you have afterwards?

Seems to me like you're very close but I have no idea what the problem is.

Last edited by hesitz (15-05-2022 16:29)

Re: Bluetooth MIDI on Raspberry Pi 4

hesitz wrote:

I'd be very skeptical of concluding that the Pi hardware has some problem with Bluetooth MIDI, there's lots of resources around that show people getting Bluetooth MIDI working on RPi's, and I know a guy who has done it.  It tended to be somewhat of a problem because most Pi distros don't come with Bluetooth MIDI support, you need to recompile the bluez package to get it.  But apparently your Ubuntu supports it with just some reconfiguration.

At this point I would go back a step and make sure that you're able to get a working MIDI connection using a USB cable.  Have you done this already?

EDIT: Whoops, going back to your older posts I see the McLarenLabs link is actually about recompiling bluez, not mere reconfiguration.  So, no, there was not technically any built-in Bluetooth Midi support in your Ubuntu distro.  You had to recompile to get it, same as with other distros on the Pi that don't come with Bluetooth Midi.  FWIW, I tried same recompile process for Bluez a couple years ago and never got it to work, though I ended up not being able to solve a problem with the recompile, gave up and started using RT-MIDI for a bit for a wireless connection to my PC, not really an option with keyboard controller to Pi solution.  If I recall correctly my problems with recompiling Bluez probably came from not using most recent version, or having to use part from an older version of the bluez package, or maybe something with dependencies installed.  Things got screwed up enough I just gave up and haven't tried again since.

When you recompiled the bluez package did everything go **exactly** as written on that MclarenLabs page.  What version of bluez did you have before the recompile, and what version did you have afterwards?

Seems to me like you're very close but I have no idea what the problem is.

This is what I did mixing various outdated infos I could gather online (step by step, it is working):


-> download BlueZ
http://www.kernel.org/pub/linux/bluetoo....64.tar.xz

cd '/home/jeremie/Documents/bluez-5.64'

sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install glib2.0
sudo apt install libdbus-1-dev libudev-dev libical-dev libreadline-dev
sudo apt-get install libasound2-dev
sudo apt-get install docutils-common

./configure --prefix=/usr --mandir=/usr/share/man --sysconfdir=/etc --localstatedir=/var --enable-experimental --enable-midi

make -j4
sudo make install
sudo reboot

After that I can actually connect the MIDI Keyboard though Bluetooth… but the data doesn't seem to be transmitted

Re: Bluetooth MIDI on Raspberry Pi 4

Jeremie wrote:

After that I can actually connect the MIDI Keyboard though Bluetooth… but the data doesn't seem to be transmitted

Yeah, seems strange.  And it may be something simple.  But at this point if it were me I would probably temporarily abandon this OS install, grab a new SD card, and go through entire process again with different OS install, e.g., maybe using this automated process that was documented against Raspberry Pi OS Lite within last 4 months:
https://github.com/Mylab6/PiBluetoothMidSetup

I assume you could skip the Maschine config part, since you have no Maschine.

The author of that github project wrote something that sounds a little strange:  "By default you still need to plug in a real usb midi device into the Raspberry PI, however it's very possible to send midi signals from software and transmit them via Bluetooh." 

Could it be that you need to attach a working USB midi device to jumpstart things and get the Bluetooth Midi connection working? . . .  To test you could attach some other usb midi device (not the keyboard with Bluetooth midi connection) and see what happens.

Last edited by hesitz (15-05-2022 21:30)

Re: Bluetooth MIDI on Raspberry Pi 4

hesitz wrote:
Jeremie wrote:

After that I can actually connect the MIDI Keyboard though Bluetooth… but the data doesn't seem to be transmitted

Yeah, seems strange.  And it may be something simple.  But at this point if it were me I would probably temporarily abandon this OS install, grab a new SD card, and go through entire process again with different OS install, e.g., maybe using this automated process that was documented against Raspberry Pi OS Lite within last 4 months:
https://github.com/Mylab6/PiBluetoothMidSetup

I assume you could skip the Maschine config part, since you have no Maschine.

The author of that github project wrote something that sounds a little strange:  "By default you still need to plug in a real usb midi device into the Raspberry PI, however it's very possible to send midi signals from software and transmit them via Bluetooh." 

Could it be that you need to attach a working USB midi device to jumpstart things and get the Bluetooth Midi connection working? . . .  To test you could attach some usb midi device (not the keyboard with Bluetooth midi connection) and see what happens.

Yeah… I'll just give up the bluetooth part here, anyway I have a screen and speakers connected with cables and everything is close to the Raspberry Pi 4 and the Piano. A USB cable will do the job I believe… I wasted too much time on the bluetooth problems now. Time to play the piano