Coder Social home page Coder Social logo

bt-speaker's People

Contributors

djh816 avatar julius112 avatar lukasjapan avatar schlimmchen avatar sylvainpelissier avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bt-speaker's Issues

1 second delay wifi adapter is disabled

heey hope someone can help me . unfortunately i cannot watch any video content with the bluetooth audio there is a 1 second delay and my wifi adapter is disabled can somebody help me ?

random silents and errors after a short time

Hello,

Thank you for sharing this project. I am able to install bt-speaker on RPi and pair a device. But there are random short silences around every 3 seconds. and after 30 seconds I get this

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.029027] Internal error: : 11 [#1] ARM

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.082299] Process bt_speaker.py (pid: 387, stack limit = 0xd8ea4188)

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.085174] Stack: (0xd8ea5dd0 to 0xd8ea6000)

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.088136] 5dc0:                                     00000001 da61a9c0 d8ea5dfc d8ea5de8

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.093978] 5de0: c04d6728 c04d6450 00000001 d8093800 d8ea5e14 d8ea5e00 c04d68a4 c04d6718

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.099795] 5e00: d8093800 00000040 d8ea5e2c d8ea5e18 c04ddb44 c04d687c 00000000 da61a9c0

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.105621] 5e20: d8ea5e64 d8ea5e30 bf3935d8 c04ddb30 c0026168 fffffff2 d8093800 d8093800

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.111541] 5e40: d7ce4dc0 00000040 00000260 d8ea5e90 d8ea4000 00000000 d8ea5e8c d8ea5e68

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.117696] 5e60: bf3c1e50 bf3934f4 00000040 d8ea5ef0 d8ea5f08 d8d6d500 00000000 00000260

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.124312] 5e80: d8ea5edc d8ea5e90 c04cd508 bf3c1df4 00000000 00000000 00000000 00000000

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.131236] 5ea0: 00000260 d8ea5ee8 00000001 00000001 00000000 00000000 00000040 d8ea5f08

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.138450] 5ec0: bedeb5e8 d8d6d500 d8ea5f80 00000000 d8ea5f4c d8ea5ee0 c0144260 c04cd474

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.145901] 5ee0: 00000260 d8ea5ef0 bedea978 00000260 00000000 00000000 00000260 d8ea5ee8

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.153425] 5f00: 00000001 00000001 d8d6d500 00000000 00000000 00000000 00000000 00000000

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.161209] 5f20: 00000000 00000000 d8e4f3c0 00000260 d8d6d500 bedea978 d8ea5f80 c000ffc4

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.169004] 5f40: d8ea5f7c d8ea5f50 c0144fa0 c014419c c0161bdc c01617a4 d8ea5f7c d8d6d500

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.176865] 5f60: d8d6d501 00000260 bedea978 c000ffc4 d8ea5fa4 d8ea5f80 c0146180 c0144f14

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.184674] 5f80: 00000000 00000000 00000077 00000a00 000002a0 00000003 00000000 d8ea5fa8

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.192525] 5fa0: c000fe40 c0146138 00000077 00000a00 0000000a bedea978 00000260 00000260

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.200352] 5fc0: 00000077 00000a00 000002a0 00000003 bedea974 01c32678 bedea978 00000000

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.208175] 5fe0: 00000000 bedea958 b6e9c504 b6e9ccb4 80000010 0000000a 00000000 00000000

Message from syslogd@raspberrypi at Jul  7 23:25:51 ...
 kernel:[   70.288533] Code: e3500000 0a000007 f5d0f000 e1902f9f (e2422001)

Software not playing sound after a while...

I don't know if it's the software or my hardware that's faulty...
Whenever I connect to the Pi after it had been inactive for a while since last using it (eg reconnecting to the Pi the next day), it won't play any sound to my 3.5mm jack.
It still connects and the bluetooth works just fine, but it won't play any sound unless I completely reboot it.

Also, a sound indicating when the Raspberry has successfully connected to a device (and also to verify that it does still play sound) would be very helpful. I might just as well suggest an "auto-reconnect" feature while I'm at it, so my Pi would always connect itself if it finds any known device..

Thanks in advance, I really do like this project!

Sound output is very quiet

This is the best solution that I could find that works with the PI 3.
But the sound output is currently very low. Is there a way to boost the output volume?

I already have the volume at 100% and I noticed it is a common problem with ALSA.

how to config

i'm install bt-speaker on raspberry 3b,but i don't know how to work.

and at the dmesg

[ 1.982751] systemd[1]: Configuration file /opt/bt-speaker/bt_speaker.service is marked executable. Please remove executable permission bits. Proceeding anyway.
[ 2.022295] systemd[1]: Cannot add dependency job for unit regenerate_ssh_host_keys.service, ignoring: Unit regenerate_ssh_host_keys.service failed to load: No such file or directory.

Sound glitches when starting audio playback.

Hi

I get some rather annoying sound glichtes (snaps or crackles) when starting the audio playback on my phone (or when changing from one app to another). I notices that this wasn't a problem before the "broken pipe fix" was implemented.
I don't know much python and nothing about bluetooth audio streaming, but the noises dissapear when i remove the following line:

self.process.stdin.write(data)

Without the fix for the broken pipe, my audio would stop playing after about 15 minutes. Connection would persist but it would just go silent.

Another system-wide bluetooth daemon

Apparently, there is no other way to contact each other via Github. So, using this way:
I wrote another bluetooth daemon target at embedded and low-powered boards:
https://github.com/mincequi/cornrow

It is fully debianized and also has a built-in equalizer (can be remote controlled via app).
Since it is utilizing gstreamer, adding further codecs and other nifty filters should be easier to integrate.
Please, tell me waht you think and potentially we might join up forces here.

Thanks.

Best regards,
Manuel

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

Cannot create directory .config/pulse

pi@raspberrypi:~ $ service bt_speaker status
● bt_speaker.service - "Simple bluetooth speaker for the Raspberry Pi"
Loaded: loaded (/opt/bt-speaker/bt_speaker.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2017-12-04 13:54:47 UTC; 24s ago
Main PID: 1164 (bt_speaker.py)
CGroup: /system.slice/bt_speaker.service
└─1164 /usr/bin/python /opt/bt-speaker/bt_speaker.py

Dec 04 13:54:47 raspberrypi systemd[1]: Started "Simple bluetooth speaker for the Raspberry Pi".
Dec 04 13:54:48 raspberrypi bt_speaker.py[1164]: Failed to create secure directory (/home/btspeaker/.config/pulse): No such file or directory
Dec 04 13:54:48 raspberrypi bt_speaker.py[1164]: Failed to load cookie file from cookie: No such file or directory
Dec 04 13:54:48 raspberrypi bt_speaker.py[1164]: Failed to create secure directory (/home/btspeaker/.config/pulse): No such file or directory
Dec 04 13:54:48 raspberrypi bt_speaker.py[1164]: Failed to load cookie file from cookie: No such file or directory
Dec 04 13:54:48 raspberrypi bt_speaker.py[1164]: Failed to create secure directory (/home/btspeaker/.config/pulse): No such file or directory
Dec 04 13:54:48 raspberrypi bt_speaker.py[1164]: Failed to load cookie file from cookie: No such file or directory
Dec 04 13:54:48 raspberrypi bt_speaker.py[1164]: ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Access denied
Dec 04 13:54:48 raspberrypi bt_speaker.py[1164]: aplay: main:788: audio open error: Connection refused

Question on usage

Hey
I have certain questions and use cases

  1. How can we uninstall this module?

  2. This module will allow only audio to be streamed from one device. But is it possible to have multiple devices/phones to stay connected? That is Pi has knowledge of all active connected devices but through user action the Pi will switch connection and only play from one of them.
    For eg, user 1 plays audio, Pi switches connection to User 1 and accepts streams. If User 2 also play audio, Pi switches connection and accepts stream from only user 2.

  3. Which also brings the question how many paired devices can it be made to remember?

  4. Can we alter the pairing behaviour? Pressing physical buttons or adding pairing code?

  5. I have a default ALSA device called dsp This applies system wide audio DSP. I assume by default the module will output any incoming stream through the default ALSA device, correct? No changes need to be made?

Sometimes IOErrors when piping to aplay

Sometimes it happens that despite successfully connecting no sound is playing. Looking at the logs I see:

Traceback (most recent call last):
Jan 26 11:21:02 raspberrypi bt_speaker.py[1859]:   File "/usr/lib/python2.7/dist-packages/gi/override
Jan 26 11:21:02 raspberrypi bt_speaker.py[1859]:     func_fdtransform = lambda _, cond, *data: callba
Jan 26 11:21:02 raspberrypi bt_speaker.py[1859]:   File "/opt/bt-speaker/bt_manager/audio.py", line 1
Jan 26 11:21:02 raspberrypi bt_speaker.py[1859]:     self.user_cb(self.user_arg)
Jan 26 11:21:02 raspberrypi bt_speaker.py[1859]:   File "/opt/bt-speaker/bt_manager/audio.py", line 5
Jan 26 11:21:02 raspberrypi bt_speaker.py[1859]:     self.raw_audio(self.read_transport())
Jan 26 11:21:02 raspberrypi bt_speaker.py[1859]:   File "/opt/bt-speaker/bt_speaker.py", line 64, in 
Jan 26 11:21:02 raspberrypi bt_speaker.py[1859]:     # pipe to the play command
Jan 26 11:21:02 raspberrypi bt_speaker.py[1859]: IOError: [Errno 32] Broken pipe

Reconnecting does not help.
Restarting bt_speaker fixes this.
This seems to be happening mostly over night. At evening before everything works great and the next morning it doesn't. But it doesn't happen every night.

I don't no what exactly is causing the IOError, but I think it would be good to handle it gracefully.
For me just doing sys.exit(1) on such an error would be enough, as systemd will immediately restart the service and everything will be working again.

I am running bt-speaker on a Raspberry Pi 1B.
(I know this is not the officially supported Hardware, but it is working really great. Much better than the pulseaudio solution I tried before.)

Kodi output and phone

Hi.
I am working on it in my car. I have a carpi with android auto etc. It works great, but my phone connects as a Headset with mic input. I deactivated it, because I have one in my car, but I would like the possibility to connect the output to kodi. So I could see what I am hearing, show visualisation, and maybe change to the next track etc.

Also the call input would be nice to accept it with the pi and make calls with it. This isn't very important to me, but would be nice and maybe others would like it.
Thanks

Demon running but no sound

Hi:
The demon is running but I get no sound, my dmesg is filled with "Bluetooth: hci0: Frame reassembly failed".

Commenting out dtparam=audio=on breaks everything

I'm trying to setup my system so that it will play the output of the bluetooth streamer to a SPI DAC on the raspberry pi (pHAT DAC). Their one line installation for the dac broke the bluetooth setup. So then I went through line by line to figure out what exactly was breaking things. It turns out that the only thing that breaks the bluetooth speaker is commenting out dtparam=audio=on in /boot/config.txt. When that is commented out, the rpi will still broadcast, but I will be unable to connect to it with my iphone over bluetooth. Removing the commented line fixes the problem. I'm running Raspbian Jessie and have a Raspberry Pi W Zero. This was done with a fresh install of the most recent version of Jessie.

Not sure what this line is loading that is essential to this library but for some reason it seems to break something.

2 bluetooth senders connected simultaneously?

Hi there,

for a relatively special use case I’m looking for a device which can act as bluetooth speaker for two senders at the same time with (smart) mixing of the two signals before output.
Any educated guess if this would be possible by slightly extending this project?
I would start with modifying the class AutoAcceptSingleAudioAgent to AutoAccept2AudioAgent, but I have no idea whether the bluetooth stack would allow a second input device.

Unable to create directories in bt_speaker user directory?

When I check the sudo systemctl status bt_speaker.service I see this error. It seems there are some permissions issues for the btspeaker user?

Oct 22 11:01:07 retropie systemd[1]: Started "Simple bluetooth speaker for the Raspberry Pi".
Oct 22 11:01:09 retropie bt_speaker.py[13467]: Failed to create secure directory (/home/btspeaker/.config/...tory
Oct 22 11:01:09 retropie bt_speaker.py[13467]: Failed to create secure directory (/home/btspeaker/.config/...tory
Oct 22 11:01:09 retropie pulseaudio[13476]: [pulseaudio] authkey.c: Failed to open cookie file '/home/btsp...tory
Oct 22 11:01:09 retropie pulseaudio[13475]: [pulseaudio] authkey.c: Failed to open cookie file '/home/btsp...tory
Oct 22 11:01:09 retropie pulseaudio[13476]: [pulseaudio] authkey.c: Failed to load authorization key '/hom...tory
Oct 22 11:01:09 retropie pulseaudio[13475]: [pulseaudio] authkey.c: Failed to load authorization key '/hom...tory
Oct 22 11:01:09 retropie pulseaudio[13476]: [pulseaudio] authkey.c: Failed to open cookie file '/home/btsp...tory
Oct 22 11:01:09 retropie pulseaudio[13475]: [pulseaudio] authkey.c: Failed to open cookie file '/home/btsp...tory
Oct 22 11:01:09 retropie pulseaudio[13476]: [pulseaudio] authkey.c: Failed to load authorization key '/hom...tory
Hint: Some lines were ellipsized, use -l to show in full.

Speaker is not discoverable

Hello,

I have a raspberry pi 3 B+, I did a fresh install and run the script as mentioned in documentation.

The service is started

● bt_speaker.service - "Simple bluetooth speaker for the Raspberry Pi"
   Loaded: loaded (/opt/bt-speaker/bt_speaker.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2018-10-17 18:47:08 UTC; 1min 34s ago
 Main PID: 452 (bt_speaker.py)
      CPU: 578ms
   CGroup: /system.slice/bt_speaker.service
           ├─452 /usr/bin/python /opt/bt-speaker/bt_speaker.py
           ├─454 /bin/sh -c aplay -f cd -
           └─455 aplay -f cd -

Oct 17 18:47:08 raspberrypi systemd[1]: Started "Simple bluetooth speaker for the Raspberry Pi".

But no device was found on my Mac or my Iphone.

The config.ini is

[bt_speaker]
play_command = aplay -f cd -
connect_command = /etc/bt_speaker/hooks/connect
disconnect_command = /etc/bt_speaker/hooks/disconnect

[bluez]
device_path = /org/bluez/hci0
discoverable = yes

[alsa]
enabled = yes
mixer = PCM
id = 0

Did I miss something ?

package install auto aborts

For some reason when i run install.sh as root, the package install aborts like this:

Do you want to continue [Y/n] Abort.

Resampling with sox play command

(new feature)
Today playing is accomplished with

aplay -f cd -

But say that we would like resample the 44.1k audio stream before piping to a CODEC, for example at 96k.

SoX allows for advanced audio manipulation and piping. Where would one start in order to add such functionality to bt-speaker? Is it at all possible to parse more elaborate commands from the config file?

Audio is laggy

Audio is laggy while android is connected ith wifi connected (wifi of android device).
HARDWARE : RPI3
WIFI DISABLED
PULSEAUDIO NOT INSTALLED

No Audio From external USB sound card

Hi there,
i'm getting no audio at all from my external sound card, the cardindex option seems to do nothing. That's my aplay -l
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA] Subdevices: 7/7 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI] Subdevices: 1/1 Subdevice #0: subdevice #0 card 1: Device [USB Sound Device], device 0: USB Audio [USB Audio] Subdevices: 0/1 Subdevice #0: subdevice #0

bt-speaker ALSA configuration with Hifiberry DAC+

Thank's for a terrific project!!! Now I would like to improve the audio output and installed the DAC+ from Hifiberry. I dont really understand how to use the alsa config in order to allow for volume control. Maybe not right to post this here, but eventually others will find some clues for how bt-speaker can be setup with a DAC on latest Rasbian.

My setup:
RPi 2 b+ with BT dongle: DIGITUS Bluetooth® 4.0 Tiny USB Adapter
Rasbian 2017-11-29-raspbian-stretch-lite.zip

config.txt, observe that I'm allowing both default RPi audio and DAC+. bt-speaker cannot connect over BT if dtparam=audio=on is commented out (as noted by others)

pi@raspberrypi:~ $ tail -7 /boot/config.txt 
# Enable audio (loads snd_bcm2835)
dtparam=audio=on

# Hifiberry
dtoverlay=hifiberry-dacplus

bt-speaker conf, without ALSA - dont understand the settings

pi@raspberrypi:~ $ cat /etc/bt_speaker/config.ini 
[bt_speaker]
play_command = aplay -f cd -
connect_command = /etc/bt_speaker/hooks/connect
disconnect_command = /etc/bt_speaker/hooks/disconnect

[bluez]
device_path = /org/bluez/hci0
discoverable = yes

[alsa]
enabled = no
mixer = PCM
id = 0
cardindex = 0

sound cards

pi@raspberrypi:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ALSA [bcm2835 ALSA], device 0: bcm2835 ALSA [bcm2835 ALSA]
  Subdevices: 7/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 0: ALSA [bcm2835 ALSA], device 1: bcm2835 ALSA [bcm2835 IEC958/HDMI]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: sndrpihifiberry [snd_rpi_hifiberry_dacplus], device 0: HiFiBerry DAC+ HiFi pcm512x-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

asound.conf

pi@raspberrypi:~ $ cat /etc/asound.conf 
pcm.!default {
  type hw card 1
}
ctl.!default {
  type hw card 1
}

amixer possibilies for card 1, i.e. the DAC, can this info be used somehow for the settings in the config?
With alsamixer its possible to adjust the volume with "Simple mixer control 'Digital',0" (number 10 if we start at 1), presently at 100%.
Its also possible to use amixer sset 'Digital' , for example

pi@raspberrypi:~ $ amixer sset 'Digital' 200
Simple mixer control 'Digital',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 207
  Mono:
  Front Left: Playback 200 [97%] [-3.50dB] [on]
  Front Right: Playback 200 [97%] [-3.50dB] [on]
pi@raspberrypi:~ $ amixer -c 1
Simple mixer control 'DSP Program',0
  Capabilities: enum
  Items: 'FIR interpolation with de-emphasis' 'Low latency IIR with de-emphasis' 'High attenuation with de-emphasis' 'Fixed process flow' 'Ringing-less low latency FIR'
  Item0: 'FIR interpolation with de-emphasis'
Simple mixer control 'Analogue',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 1
  Mono:
  Front Left: Playback 1 [100%] [0.00dB]
  Front Right: Playback 1 [100%] [0.00dB]
Simple mixer control 'Analogue Playback Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 1
  Front Left: 1 [100%] [0.80dB]
  Front Right: 1 [100%] [0.80dB]
Simple mixer control 'Auto Mute',0
  Capabilities: pswitch
  Playback channels: Front Left - Front Right
  Mono:
  Front Left: Playback [on]
  Front Right: Playback [on]
Simple mixer control 'Auto Mute Mono',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Auto Mute Time Left',0
  Capabilities: enum
  Items: '21ms' '106ms' '213ms' '533ms' '1.07s' '2.13s' '5.33s' '10.66s'
  Item0: '21ms'
Simple mixer control 'Auto Mute Time Right',0
  Capabilities: enum
  Items: '21ms' '106ms' '213ms' '533ms' '1.07s' '2.13s' '5.33s' '10.66s'
  Item0: '21ms'
Simple mixer control 'Clock Missing Period',0
  Capabilities: enum
  Items: '1s' '2s' '3s' '4s' '5s' '6s' '7s' '8s'
  Item0: '1s'
Simple mixer control 'Deemphasis',0
  Capabilities: pswitch pswitch-joined
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'Digital',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 207
  Mono:
  Front Left: Playback 207 [100%] [0.00dB] [on]
  Front Right: Playback 206 [100%] [-0.50dB] [on]
Simple mixer control 'Max Overclock DAC',0
  Capabilities: volume volume-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 40
  Mono: 0 [0%]
Simple mixer control 'Max Overclock DSP',0
  Capabilities: volume volume-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 40
  Mono: 0 [0%]
Simple mixer control 'Max Overclock PLL',0
  Capabilities: volume volume-joined
  Playback channels: Mono
  Capture channels: Mono
  Limits: 0 - 20
  Mono: 0 [0%]
Simple mixer control 'Volume Ramp Down Emergency Rate',0
  Capabilities: enum
  Items: '1 sample/update' '2 samples/update' '4 samples/update' 'Immediate'
  Item0: 'Immediate'
Simple mixer control 'Volume Ramp Down Emergency Step',0
  Capabilities: enum
  Items: '4dB/step' '2dB/step' '1dB/step' '0.5dB/step'
  Item0: '4dB/step'
Simple mixer control 'Volume Ramp Down Rate',0
  Capabilities: enum
  Items: '1 sample/update' '2 samples/update' '4 samples/update' 'Immediate'
  Item0: '1 sample/update'
Simple mixer control 'Volume Ramp Down Step',0
  Capabilities: enum
  Items: '4dB/step' '2dB/step' '1dB/step' '0.5dB/step'
  Item0: '1dB/step'
Simple mixer control 'Volume Ramp Up Rate',0
  Capabilities: enum
  Items: '1 sample/update' '2 samples/update' '4 samples/update' 'Immediate'
  Item0: '1 sample/update'
Simple mixer control 'Volume Ramp Up Step',0
  Capabilities: enum
  Items: '4dB/step' '2dB/step' '1dB/step' '0.5dB/step'
  Item0: '1dB/step'

High CPU Usage even if unused

Hi all,

I recognized an issue in a RPI3 using bt speaker to use the Pi as an audio transceiver. First of all, bt-speaker is working fine without problems. I do not use the builtin WLAN module to avoid the sound problems.

After some time, even if not used, the python-process of bt-speaker constantly causes high cpu usage (100% on one core). How can I help to investigate?

Regards,

Exception: <type 'exceptions.OSError'>

Hi , I tried to start the daemon manually and i get thi stuff ( raspberry 3 ).
I see the device on my phone and it tries to connect to it but suddenly the connection drops..

any idea ?

thanks

Marco

Device connected. device=/org/bluez/hci0/dev_B4_9C_DF_3C_D9_26
Hiding adapter from all devices.

  • ogg123 /usr/share/sounds/freedesktop/stereo/service-login.oga

Audio Device: Advanced Linux Sound Architecture (ALSA) output

Playing: /usr/share/sounds/freedesktop/stereo/service-login.oga
Ogg Vorbis stream: 2 channel, 22050 Hz

Done.
Exception: <type 'exceptions.OSError'>
Device disconnected. device=/org/bluez/hci0/dev_B4_9C_DF_3C_D9_26
Showing adapter to all devices.

  • o

Auto reconnect

Is there a function to connect to a device?

I rewrote the handler and after no device is connected it try's to reconnect to the last connected device but the method to connect to a device using the uuid seems to not exist?

No connect/disconnect audio

Installed a HiFiBerry DAC+. After a little work, got sound to stream flawlessly through bluetooth.

My issue is that with the onboard sound, everything worked. Now the connect/disconnect audio doesn't play. I'm not sure what to do. Disabling the onboard sound seems to break bt-speaker, and I've tried a bunch of other suggestions, to no avail.

open audio device only when used

thanks for the great job!
I installed it successfully on my i686 pc (codec use PLATFORM = mmx).
it is possible to open audio device only when used? when bt device is connect and play?

bt-speaker crashing when using dmix with other sources

When running on a Raspberry I encountered following problems with bt-speaker:
the service crashed with a python stacktrace and ceased working. The connection between bt-speaker and client was still running. Only restarting bt-speaker fixes the issue.

How to repeat:

  • use alsa dmix plugin
  • start mpd and bt-speaker
  • connect to bt-speaker with client
  • start playing music on mpd and stop it

Bt-speaker crashes with this messages repeatedly.

I used it with dmix for multiple sources and combined both stereo channels to mono on each output channel. Config

Service want start - ERROR:dbus.connection

I tried to get this up and running and when the service is about to start i get following message.
Am I missing something?

bluetoothctl -v => 5.43
Linux raspberrypi 4.9.76-v7+ #1076 SMP Wed Jan 10 17:34:49 GMT 2018 armv7l GNU/Linux

Jan 13 13:24:07 raspberrypi bt_speaker.py[1968]: ERROR:dbus.connection:Unable to set arguments ('/endpoint/a2dpsink', dbus.Dictionary({u'Codec': dbus.Byte(0), u'UUID': dbus.String(u'0000110B-0000-1000-8000-00805F9B34FB'), u'DelayReporting': dbus.Boolean(True), u'Capabilities': dbus.Array([dbus.Byte(255), dbus.Byte(255), dbus.Byte(2), dbus.Byte(64)], signature=None)}, signature=None)) according to signature None: <type 'exceptions.TypeError'>: an integer is required
Jan 13 13:24:07 raspberrypi bt_speaker.py[1968]: an integer is required
Jan 13 13:24:07 raspberrypi systemd[1]: bt_speaker.service: Service hold-off time over, scheduling restart.

USB audio card problem

Hi, I installed your project on my pi zero w but now I am having a problem. I can find and connect to it only when the usb audio card is not set as default audio device and without it I can not sound it :( , what can I do to solve it?
Thanks you for your work anyway

Require client pin?

This is really handy and works great on a Pi Zero W. One question. For my car I'd like to require connecting clients to enter a pin because, sometimes we can't have nice things. I've been playing with this block of agent.py but haven't figured out the magic. Thoughts? It's not critical- I'll dig into DBUS if I need to. Thx!

def __init__(self,
                 path='/test/agent',
                 auto_authorize_connections=True,
                 default_pin_code='0000',
                 default_pass_key=0,   # Range: 0-999999
                 cb_notify_on_release=None,
                 cb_notify_on_authorize=None,
                 cb_notify_on_request_pin_code=None,
                 cb_notify_on_request_pass_key=None,
                 cb_notify_on_display_pass_key=None,
                 cb_notify_on_request_confirmation=None,
                 cb_notify_on_confirm_mode_change=None,
                 cb_notify_on_cancel=None):

Volume too low on connect

Whenever I connect with my phone the start volume is too low. I always have to manually turn up the volume.
I am not sure if this is an android, RPi1 or bt-speaker -specific problem.
Would it be possible to specify an on-connect-default volume in the config, or even better store the last volume and apply it at subsequent connects?

AVRCP with iPhone: Strange Volume behaviour

Thank you for this piece of software, it's just fantastic. Love the simplicity, especially compared to other solutions! 😊

I've got a strange issue with AVRCP from my iPhone running iOS11:
I always output the sound through the audio jack, so I set cardindex = 1. If I connect from macOS I can set the volume remotly without problems. With the iPhone I can also set volume, but if its set to 48% or above output switches to HDMI (iPhone jumps 6%, from 42>48% on 1 button press). When I set to 42% or lower it switches back to jack since I've set that in config.

Any idea where to search for debug?

Dbus connection error

OS: Raspbian 9.8, kernel 4.9.35
When I check the status of the service I get the following error. Any help would be appreciated. Do tell if any other info would be useful.

Mar 15 22:43:19 raspberrypi pulseaudio[1647]: [pulseaudio] server-lookup.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11 Mar 15 22:43:19 raspberrypi pulseaudio[1647]: [pulseaudio] main.c: Unable to contact D-Bus: org.c: Unable to contact D-Bus: org.freedesktop.DBus.Error.NotSupported: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11 Mar 15 22:43:19 raspberrypi pulseaudio[1651]: [pulseaudio] pid.c: Daemon already running.

no sound output

I am running Linux raspberrypi 4.14.52-v7+ #1123 SMP Wed Jun 27 17:35:49 BST 2018 armv7l GNU/Linux on a Pi 3 Model B.

Everything in the logs looks normal and I am able to pair two Android devices and transmit audio.
However, no audio is played on the Pi. I tested with another audio source (Youtube) directly on the Pi and it works without issues.

What else can I check?

Jul 25 13:42:22 raspberrypi kernel: [ 17.835836] Bluetooth: Core ver 2.22 Jul 25 13:42:22 raspberrypi kernel: [ 17.835965] NET: Registered protocol family 31 Jul 25 13:42:22 raspberrypi kernel: [ 17.835972] Bluetooth: HCI device and connection manager initialized Jul 25 13:42:22 raspberrypi kernel: [ 17.837503] Bluetooth: HCI socket layer initialized Jul 25 13:42:22 raspberrypi kernel: [ 17.837529] Bluetooth: L2CAP socket layer initialized Jul 25 13:42:22 raspberrypi kernel: [ 17.837581] Bluetooth: SCO socket layer initialized Jul 25 13:42:22 raspberrypi kernel: [ 17.853566] Bluetooth: HCI UART driver ver 2.3 Jul 25 13:42:22 raspberrypi kernel: [ 17.853580] Bluetooth: HCI UART protocol H4 registered Jul 25 13:42:22 raspberrypi kernel: [ 17.853586] Bluetooth: HCI UART protocol Three-wire (H5) registered Jul 25 13:42:22 raspberrypi kernel: [ 17.853802] Bluetooth: HCI UART protocol Broadcom registered Jul 25 13:42:23 raspberrypi kernel: [ 17.972109] Bluetooth: BNEP (Ethernet Emulation) ver 1.3 Jul 25 13:42:23 raspberrypi kernel: [ 17.972119] Bluetooth: BNEP filters: protocol multicast Jul 25 13:42:23 raspberrypi kernel: [ 17.972134] Bluetooth: BNEP socket layer initialized Jul 25 13:42:23 raspberrypi kernel: [ 18.162852] Bluetooth: RFCOMM TTY layer initialized Jul 25 13:42:23 raspberrypi kernel: [ 18.162939] Bluetooth: RFCOMM socket layer initialized Jul 25 13:42:23 raspberrypi kernel: [ 18.163680] Bluetooth: RFCOMM ver 1.11 Jul 25 13:44:06 raspberrypi kernel: [ 88.052067] input: 9C:65:B0:53:4A:EA as /devices/virtual/input/input0 Jul 25 13:47:44 raspberrypi kernel: [ 306.103269] input: 9C:65:B0:53:4A:EA as /devices/virtual/input/input1 Jul 25 13:48:30 raspberrypi kernel: [ 352.117235] input: 9C:65:B0:53:4A:EA as /devices/virtual/input/input2

Sound is very distorted (only) when connected to macOS

In my setup I discovered a very strange behaviour: bt-speaker works fine on the Raspberry Pi 3 (USB Audio, USB Bluetooth Adapter, Wi-Fi and internal Bluetooth disabled).

However when I try to connect from a Mac (macOS), the sound is very distorted. This cannot relate to the known Raspberry Pi Bluetooth/Wi-Fi issues (as other devices work), but may be a missing piece in the decoder code.

When I change the play_command to cat > /tmp/out I can save the decoded stream and later play with aplay -f cd /tmp/out. I’ll attach the file, which may give an indica
tion what goes wrong here… (you can play them with aplay -f cd out.pcm)

examples.zip

(Playing A2DP via BlueALSA/BlueALSA-aplay works also fine, for all devices including the macOS ones)

Unknown PCM cards.pcm.front

it connects, and play the welcome sound
and when trying to play audio : nothing to hear
any idea ?

seems to bug "Unknown PCM cards.pcm.front"

pi@raspberrypi:/opt/bt-speaker $ sudo ./bt_speaker.py
Showing adapter to all devices.
Device connected. device=/org/bluez/hci0/dev_C0_EE_FB_D4_FA_37
Hiding adapter from all devices.

  • ogg123 /usr/share/sounds/freedesktop/stereo/service-login.oga

Périphérique audio : Advanced Linux Sound Architecture (ALSA) output

Écoute de : /usr/share/sounds/freedesktop/stereo/service-login.oga
Ogg Vorbis stream: 2 channel, 22050 Hz
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front

Stuttering audio and buffer underruns when WiFi is enabled

I tested this with my phone and it worked fine but when I pair my Amazon echo dot, the playback is interrupted once every one to two seconds. Has anyone else experienced this or know a fix?
I know it's not a signal strength issue because the two are right beside each other. Thanks!

Hiding adapter from all devices.
underrun!!! (at least 9.096 ms long)
underrun!!! (at least 0.642 ms long)
underrun!!! (at least 11.836 ms long)
underrun!!! (at least 12.320 ms long)
underrun!!! (at least 25.990 ms long)
underrun!!! (at least 73.289 ms long)
underrun!!! (at least 53.062 ms long)
underrun!!! (at least 19.260 ms long)
underrun!!! (at least 55.009 ms long)
underrun!!! (at least 20.370 ms long)
underrun!!! (at least 62.025 ms long)

Hang when I move the mouse

When using bt-speaker (i.e. when I have connected my phone to play music), if I move the mouse my whole rpi hangs and needs to be unplugged to reboot.

iPhone AVRCP Volume Control

Hello, first off all: Congratulations, great work! I haven't seen any other implementation of A2DP that needs nearly no configuration. The only problem, I currently have is that I can't control the ALSA volume on the iPhone. I tested it with an iPhone SE (iOS 10.3.1) and iPhone touch 4G (iOS 6.X). However, it works perfectly fine on an Android phone. So I assume the configuration is correct. Do you have any idea, what the problem is?

media controls

would it be possible to add simple media controls like play/pause and next/previous track?

Script for connect/disconnect is called immediately

I missed conversation about my pull request! The reason I hooked into the code for implementing Sonoff was actually to implement timeout for calling script and add functionality to make HTTP call as many relays controlling power support it. Mainly this was because I didn't wanted bt-speaker to turn off power immediately someone disconnect from BT. Implementing that within scripts require to run them as another daemons or have a timeout functionality within controller itself. Would you agree to improvement to run script or call http with timeout value instead?

on-connect and on-disconnect audio does not play, aplay is blocking

Hello,

Great project. I am trying to tinker with this to work for my needs.

One issue I have run into is that the service which streams the audio appears to block the alsa sink device from other sources. When I connect to the speaker, I get the following output:

Device connected. device=/org/bluez/hci0/dev_14_A3_64_58_DB_F9
Hiding adapter from all devices.
aplay: main:722: audio open error: Device or resource busy

Similarly on disconnect:

Device disconnected. device=/org/bluez/hci0/dev_14_A3_64_58_DB_F9
Showing adapter to all devices.
aplay: main:722: audio open error: Device or resource busy

But I can play audio just fine (except for the WiFi-caused underruns in issue #4 ).

Here is my /etc/bt_speaker/config.ini file:

[bt_speaker]
play_command = aplay -D plug0 -f cd -
connect_command = aplay -D plug0 /usr/share/sounds/freedesktop/stereo/service-login.wav
disconnect_command = aplay -D plug0 /usr/share/sounds/freedesktop/stereo/service-logout.wav

[bluez]
device_path = /org/bluez/hci0

[alsa]
mixer = PCM

Let me know what I can try.

Default user has not enough permissions

When the default btspeaker user is used on the latest Raspbian (Stretch), the user does not have enough permissions on the DBUS. Running the script as root works perfect.

$ python bt_speaker.py
ERROR:dbus.proxies:Introspect error on :1.4:/org/bluez/hci0: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.AccessDenied: Rejected send message, 2 matched rules; type="method_call", sender=":1.24" (uid=1001 pid=698 comm="python bt_speaker.py ") interface="org.freedesktop.DBus.Introspectable" member="Introspect" error name="(unset)" requested_reply="0" destination=":1.4" (uid=0 pid=469 comm="/usr/lib/bluetooth/bluetoothd ")
ERROR:dbus.connection:Unable to set arguments ('/endpoint/a2dpsink', dbus.Dictionary({u'Codec': dbus.Byte(0), u'UUID': dbus.String(u'0000110B-0000-1000-8000-00805F9B34FB'), u'DelayReporting': dbus.Boolean(True), u'Capabilities': dbus.Array([dbus.Byte(255), dbus.Byte(255), dbus.Byte(2), dbus.Byte(64)], signature=None)}, signature=None)) according to signature None: <type 'exceptions.TypeError'>: an integer is required
an integer is required
aplay: playback:2787: read error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.