bt-speaker
bt-speaker copied to clipboard
Out of sync sound/grainy
Disclaimer: Really new at linux/raspberry pi
I installed bt_speaker yesterday and it played with out issues. Long story, but bottom line the pi was erased before I could back it up. Now with the same installation the audio quality is terrible. It stays connected but the audio grainy and seems to be playing faster short skips in audio. I am connected via ethernet.
Any advice would be helpful
Are you using a Pi3? Have you disabled Wifi (dtoverlay @/boot/config.txt ?) I can confirm that there are sometimes problems with the internal bluetooth on Pi3 if the cpu load is high or wifi used. You can try an external bluetooth adapter - this works better!
Another possibility I can think of could be pulseaudio if it is installed.
AFAIK, many distributions will tweak the alsa config so that aplay will send data to the pulse daemon instead of the hardware on default.
I am using the Pi3 and disabled wifi via config.txt. It appears that the problem only occurs with android devices, a friend's iOS device was able to connect and play music flawlessly. When the iOS was first connected the same issues persisted then it seemed to stop and restarted playing perfectly. I removed pulseaudio prior to install of this package.
Do you see some errors when running "dmesg" after the problem occured? I have some errors indicating dropped frames. That was the reason to choose an external usb bluetooth adapter.
I'm seeing the same: iOS plays fine, while Android plays speeded up with gaps.
The sound I'm hearing is consistent with receiving a few seconds of input, playing it 10% too fast (as if playing 44.1 khz sound at 48 khz) and then going silent for a fraction of a second until more audio arrives. I can post an audio recording if that would be helpful.
I don't see anything relevant in dmesg
. Are there any other logs I should look for?
More:
The sound is speeded up, but I don't think it's changed in pitch. So perhaps it's not just a sample-rate mismatch.
Here is the relevant log snipped from journalctl
:
Dec 11 02:19:22 keylime kernel: input: CC:FA:00:35:D2:A4 as /devices/virtual/input/input3
Dec 11 02:19:22 keylime bt_speaker.py[29654]: Audio Device: Advanced Linux Sound Architecture (ALSA) output
Dec 11 02:19:22 keylime bt_speaker.py[29654]: Playing: /usr/share/sounds/freedesktop/stereo/service-login.oga
Dec 11 02:19:22 keylime bt_speaker.py[29654]: Ogg Vorbis stream: 2 channel, 22050 Hz
Dec 11 02:19:22 keylime bt_speaker.py[29654]: ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
Dec 11 02:19:23 keylime bluetoothd[658]: /org/bluez/hci0/dev_CC_FA_00_35_D2_A4/fd1: fd(23) ready
Dec 11 02:19:23 keylime bt_speaker.py[29654]: [267B blob data]
Dec 11 02:19:24 keylime bt_speaker.py[29654]: [403B blob data]
Dec 11 02:19:24 keylime bt_speaker.py[29654]: Done.
Dec 11 02:19:26 keylime bt_speaker.py[29654]: underrun!!! (at least 34.199 ms long)
Dec 11 02:19:29 keylime bt_speaker.py[29654]: underrun!!! (at least 816.634 ms long)
Dec 11 02:19:31 keylime bt_speaker.py[29654]: underrun!!! (at least 11.746 ms long)
Dec 11 02:19:35 keylime bt_speaker.py[29654]: underrun!!! (at least 65.602 ms long)
Dec 11 02:19:37 keylime bt_speaker.py[29654]: underrun!!! (at least 61.937 ms long)
Dec 11 02:19:40 keylime bt_speaker.py[29654]: underrun!!! (at least 52.356 ms long)
Dec 11 02:19:43 keylime bt_speaker.py[29654]: underrun!!! (at least 42.755 ms long)
Dec 11 02:19:45 keylime bt_speaker.py[29654]: underrun!!! (at least 2.808 ms long)
Dec 11 02:19:48 keylime bt_speaker.py[29654]: underrun!!! (at least 40.353 ms long)
Dec 11 02:19:50 keylime bt_speaker.py[29654]: underrun!!! (at least 1.242 ms long)
Dec 11 02:19:53 keylime bt_speaker.py[29654]: underrun!!! (at least 55.258 ms long)
Dec 11 02:19:55 keylime bt_speaker.py[29654]: underrun!!! (at least 46.783 ms long)
Dec 11 02:19:58 keylime bt_speaker.py[29654]: underrun!!! (at least 11.559 ms long)
Dec 11 02:20:00 keylime bt_speaker.py[29654]: underrun!!! (at least 46.356 ms long)
Dec 11 02:20:03 keylime bt_speaker.py[29654]: underrun!!! (at least 109.895 ms long)
Dec 11 02:20:05 keylime bt_speaker.py[29654]: underrun!!! (at least 12.360 ms long)
Dec 11 02:20:07 keylime bt_speaker.py[29654]: underrun!!! (at least 43.662 ms long)
Dec 11 02:20:10 keylime bt_speaker.py[29654]: underrun!!! (at least 6.694 ms long)
Dec 11 02:20:11 keylime dbus[471]: [system] Rejected send message, 2 matched rules; type="error", sender=":1.6" (uid=1001 pid=29654 comm="/usr/bin/python /opt/bt-sp
Dec 11 02:20:12 keylime bt_speaker.py[29654]: Audio Device: Advanced Linux Sound Architecture (ALSA) output
Dec 11 02:20:12 keylime bt_speaker.py[29654]: Playing: /usr/share/sounds/freedesktop/stereo/service-logout.oga
Dec 11 02:20:12 keylime bt_speaker.py[29654]: Ogg Vorbis stream: 2 channel, 22050 Hz
Dec 11 02:20:12 keylime bt_speaker.py[29654]: ALSA lib pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
Dec 11 02:20:13 keylime bt_speaker.py[29654]: [555B blob data]
Dec 11 02:20:13 keylime bt_speaker.py[29654]: Done.
The client device in question is a four-year-old Nexus 5 with Android 6.0.1. I can test on something a little more modern if it matters.
Hi,
I have the exact same error: When I connect from an android device (two different devices tested), then I get a "grainy", sped-up version of the sound with regular drop-outs. For me it also looks like the sound was played too fast and then the buffer has to be refilled. When I connect from my laptop, the playback works without any problem.
I did deactivate the onboard wifi, and I'm connected via LAN. In the logfiles I can see the underrun when connected with my android devices, but not when connected with my laptop.
Do you have any idea how this problem can be fixed? Can I provide more information or help somehow?
Thanks for your work! Christof
Can you guys test if https://github.com/lukasjapan/bt-speaker/issues/4#issuecomment-404271003 helps workaround this problem?
I can confirm this. WiFi is off. Streaming from Android 9 device works well. Streaming from Samsung Smart TV has regular drop-outs (underruns...) + sped up audio.
Also, I get this error before the underruns... upon connection:
Aug 23 13:50:10 raspberrypi bt_speaker.py[3485]: Playing raw data 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, St ereo Aug 23 13:50:13 raspberrypi bt_speaker.py[3485]: + ogg123 /usr/share/sounds/freedesktop/stereo/service-login.oga Aug 23 13:50:13 raspberrypi bt_speaker.py[3485]: [2B blob data] Aug 23 13:50:13 raspberrypi bt_speaker.py[3485]: Audio Device: Advanced Linux Sound Architecture (ALSA) output Aug 23 13:50:13 raspberrypi bt_speaker.py[3485]: [2B blob data] Aug 23 13:50:13 raspberrypi bt_speaker.py[3485]: [65B blob data] Aug 23 13:50:13 raspberrypi bt_speaker.py[3485]: [40B blob data] Aug 23 13:50:13 raspberrypi bt_speaker.py[3485]: ALSA lib confmisc.c:1281:(snd_func_refer) Unable to find definition 'car$ s.bcm2835_alsa.pcm.front.0:CARD=0' Aug 23 13:50:13 raspberrypi bt_speaker.py[3485]: ALSA lib conf.c:4528:(_snd_config_evaluate) function snd_func_refer retu$ ned error: No such file or directory Aug 23 13:50:13 raspberrypi bt_speaker.py[3485]: ALSA lib conf.c:5007:(snd_config_expand) Evaluate error: No such file or directory Aug 23 13:50:13 raspberrypi bt_speaker.py[3485]: ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM front Aug 23 13:50:13 raspberrypi bt_speaker.py[3485]: [33B blob data] Aug 23 13:50:13 raspberrypi bt_speaker.py[3485]: underrun!!! (at least 28.800 ms long)
probably an error negotiating frequencies? can a custom aplay setting solve the problem?
thank you for any ideas
EDIT:
I'm using external USB audio card (DAC) but this does not affect performance in any way when streaming audio from another source (e.g. from an Android 9 phone)
For me I had to adapt /etc/bt_speaker/config.ini
:
play_command = aplay -Dplug:default -f cd -
Now it works flawlessly with a external USB card.