[TUTORIAL] Bluetooth Audio on latest Retropie
-
DISCLAIMER : Please excuse any bad formatting/posting in the wrong category, but I want to share this with those with the same issues as me.
In the newest version of retropie, using pulseaudio with bluetooth devices leaves any games launched on a black screen until pulseaudio is killed and restarted remotely - this does not seem like a good option then. Thanks to some random redditor, I found the package bluez-alsa and spent a while setting it up.
Guide
- SSH into or connect a keyboard to your pi (I recommend SSH with PuTTY)
- Run the following
sudo apt-get update
sudo apt-get install bluez
sudo apt-get install libsndfile
sudo apt-get install libbluetooth-dev - Install dependecies
To build from source download from:
sbc - https://git.kernel.org/pub/scm/bluetooth/sbc.git
fdk-aac - https://github.com/mstorsjo/fdk-aac
bluez-alsa - https://github.com/Arkq/bluez-alsa
Installing from my packages (I built these on the Pi Zero and I'm not sure if these work at all)-
Install in order:
sbc - wget https://www.dropbox.com/s/86d3ll1tyhepnlm/sbc_1.3-1_armhf.deb
fdk-aac - wget https://www.dropbox.com/s/hrlpp2njso3dzu8/fdk-aac_0.1-1_armhf.deb
bluez-alsa - wget https://www.dropbox.com/s/f0laoezon8hvwmm/bluez-alsa_1.2.0-1_armhf.deb
Use sudo dpkg -i followed by the filename to install.
Now do this:
wget https://www.dropbox.com/s/pfvrm2s93gujz2o/bluez-alsa.zip
sudo unzip -d /usr/lib/arm-linux-gnueabihf/alsa-lib/ bluez-alsa.zip
Reboot - run sudo nano /etc/rc.local
Before the line that says exit, add a line and type sudo bluealsa &
ctrl+o
ctrl+x
reboot - run sudo bluetoothctl (connecting using the retropie bluetooth caused me some issues)
Then type:
power on
scan on
Find the mac address of your audio device, write it down for later.
trust xx:xx:xx:xx:xx:xx
pair xx:xx:xx:xx:xx:xx
connect xx:xx:xx:xx:xx:xx - sudo nano /etc/asound.conf
Use this template https://www.dropbox.com/s/kotq703r6hso9r5/asound.conf
Replace xx:xx:xx:xx:xx:xx with your MAC address and A description of your device with a description of your device and paste into your terminal, replacing all contents that were already there.
ctrl+o
ctrl+x
Now, run this. Replace xx:xx:xx:xx:xx:xx with your MAC once again.
cat ~/.asoundrc
defaults.bluealsa.interface "hci0"
defaults.bluealsa.device "XX:XX:XX:XX:XX:XX"
defaults.bluealsa.profile "a2dp"
reboot - In retropie select the config and click bluetooth.
Now select "Connect Now to all registered devices."
DO NOT PAIR THE AUDIO DEVICE IN RETROPIE - THIS WILL MAKE YOU HAVE TO RE-DO STEP 5, AFTER TYPING remove xx:xx:xx:xx:xx:xx AND REBOOTING.
Go back to retropie and test audio. It should work! If it doesn't, but your device is connected, reboot your bluetooth audio device and try this step again.
Feel free to reply with any issues.
-
@dawidekziaja please add a "tutorial" tag to the thread
-
I might not be able to try this until the weekend, but thanks for sharing this in great details. I tried a lot of the same steps (I might even have been the person to share bluez-alsa link on reddit). I didn't understand when / how to do step 6/7 so I am super excited.
While I am sure it will be some time before retropie converts to new base image "Stretch" as that uses bluez-alsa by default (not sure if in the minimal image). I would assume that would at least save the first few steps.
I will post back when I get it working, and might suggest you post on Reddit as well, since I would see posts every month or so and try to respond with all the info I had.
-
well stuck at the begining : "sudo apt-get install libsndfile"
unable to locate package libsndfile ... -
Hello - I am also unable to get this working. The "sudo apt-get install libsndfile" command gives error: "unable to locate package libsndfile".
In my opinion, unless I am truly missing something here, this method does not work - in fact, I am unsure how to "undo" these changes and thus have to rebuild my retropie as audio is now giving all sorts of errors.
-
-
Do you have any audio lag? With the new Stretch Image steps 1-4 are no longer needed (at least not for me). You do need to reinstall bluesalsa if using the beta retropie stretch image (sudo apt-get install bluealsa).
I apparently have a poor bluetooth headphone set as it won't stay connected, but my bose soundlink mini does connect up fine and work. It just has 1 secondish audio lag, which at least for me is not something I can tolerate. I haven't been able to google anything to see if there is a setting to reduce the buffer or something to try and reduce the lag.
-
@alucard_xs try this instead -> "libsndfile1"
-
This tutorial is awesome I’ve got Bluetooth working on the desktop and Lodi sections of my retropie. I just can’t get It for the games and emulation station. I also couldn’t get this code to work it says no such file.
cat ~/.asoundrc
defaults.bluealsa.interface "hci0"
defaults.bluealsa.device "XX:XX:XX:XX:XX:XX"
defaults.bluealsa.profile "a2dp"Any help would be great I e almost got my ultimate entertainment system set up.
60” 4K lcd, Retropie, desktop, kodi, Xbox wireless controller and jbl xtreme. Hours of fun for anyone.
-
@DoctorDuck
I believe I had to create the file (so it loads automatically on boot). I haven't played with it in a long time. You should be able to run bluetoothctl to trust, pair and connect via SSH. From there it should work, you might have to restart emulation station. You can copy a wav file to the pi and run it via SSH as well to test. I think it is just "aplay yourfile.wav". You would have to pair this each time, which is why that .asoundrc file is important.Are you trying to use it for music or games?
Games won't be useful. I was able to get it to working on 4.4, but no matter what always a 1 second delay. This is due to the codec and limitation of raspberry pi bluetooth chip. It doesn't support AptX (just A2DP), AptX is needed for realtime audio. You can get a bluetooth adapter that supports APTX and plugs into the audio jack then get a speaker/headphones that supports AptX as well to make it work if you really want to.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.