Open alexjaw opened 6 years ago
Hello @alexjaw,
I experienced a similar problem. For me changing the config.ini in /etc/bt_speaker/ to
[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 = Digital
id = 0
cardindex = 0
fixed some of the more obvious playback issues. You might have to change the cardindex to 1 in addition.
I had moderate success with specifying the usb device in the "play_command" of config.ini (I am using a HRT microStreamer DAC) and adjusting the alsa cardindex.
[bt_speaker]
play_command = aplay -D default:CARD=microStreamer -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
cardindex = 1
The device name I found using aplay -L
(see https://die-antwort.eu/techblog/2017-12-raspberry-pi-usb-audio-interface-command-line/ for a helpful guide).
However playback stutters every few seconds and the Raspberry Pi Zero W that I am running this on freezes completely after about thirty seconds.
I'd like to share my config as after long hours of trying out different setups, I got to a point where bt_speaker works flawlessly with my DAC soundcard, so I can connect to my Pi via Bluetooth, listen to music from my smartphones, control Pi volume with them, and hear connect/disconnect sounds.
My hardware:
Raspberry Pi Zero W
HiFiBerry-compatible 5102A-based DAC from Aliexpress (https://www.aliexpress.com/item/Interface-I2S-PCM5102-DAC-Decoder-GY-PCM5102-I2S-Player-Module-For-Raspberry-Pi-pHAT-Format-Board/32833996405.html?spm=a2g0s.9042311.0.0.11894c4dDi4J3J) - with SCK connected to ground
My OS: Raspbian Stretch Lite 4.14.79+ (2018-11-13-raspbian-stretch-lite)
/boot/config.txt:
#dtparam=audio=on
- built-in sound device driver commented outdtoverlay=hifiberry-dac
- HiFiBerry driver addedaplay -l
returns the following:
**** List of PLAYBACK Hardware Devices ****
card 0: sndrpihifiberry [snd_rpi_hifiberry_dac], device 0: HifiBerry DAC HiFi pcm5102a-hifi-0 []
Subdevices: 1/1
Subdevice #0: subdevice #0
ALSA config (usr/share/alsa/alsa.conf
):
pcm.hifiberry {
type hw
card 0
device 0
}
pcm.dmixer {
type dmix
ipc_key 1024
ipc_perm 0666
slave.pcm "hifiberry"
slave {
period_time 0
period_size 1024
buffer_size 8192
rate 44100
}
bindings {
0 0
1 1
}
}
ctl.dmixer {
type hw
card 0
}
pcm.softvol {
type softvol
slave.pcm "dmixer"
control {
name "Master"
card 0
}
}
pcm.!default {
type plug
slave.pcm "softvol"
}
pcm.front pcm.default
amixer
returns the following:
pi@raspberrypi:~ $ amixer
Simple mixer control 'Master',0
Capabilities: volume
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: 0 - 255
Front Left: 255 [100%]
Front Right: 255 [100%]
bt_speaker config (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 = yes
mixer = Master
id = 0
cardindex = 0
I hope it helps!
This is great everyone! I'm using the HiFiBerry as a DSP processor and have a similar configuration. If you're curious, I have created a Loopback
device in ALSA using sudo modprobe snd-aloop
, such that I can use a dsnoop
PCM to listen to the Loopback
card in my DSP program and then route it to the output
PCM.
My asound.conf
is:
pcm.!default {
type plug
slave.pcm "input"
}
ctl.!default {
type hw
card sndrpihifiberry
}
pcm.input {
type plug
slave.pcm "hw:Loopback,0,0"
}
pcm.snoop {
type plug
slave.pcm {
type dsnoop
ipc_key 1024
slave.pcm "hw:Loopback,1,0"
}
}
pcm.output {
type plug
slave.pcm "master_volume"
}
pcm.master_volume {
type softvol
slave.pcm "dmix:sndrpihifiberry"
control.name "Master"
control.card sndrpihifiberry
}
The bt_speaker
service then plays the audio to the input
PCM. The etc/bt_speaker/config.ini
has:
[bt_speaker]
play_command = aplay -D input -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 = Master
id = 0
cardindex = 1
Note that Loopback
is now card 0 and sndrpihifiberry
is card 1.
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)
bt-speaker conf, without ALSA - dont understand the settings
sound cards
asound.conf
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