Bluetooth-Audio -> SnapCast

Hello Forum!
Mopidy runs with Snapcast for almost 2 years really great.
In addition to Internet radio, I have also connected YouTube Music and SoundCloud.
Through SnapCast I have also managed the connection of UPnP and AirPlay (although I have no Apple devices).
Now somehow the connection of Bluetooth is still missing.

Mopidy and SnapCast are running on a Raspberry Pi 4B, which has a Bluetooth chip.
I would like to use Bluetooth as an audio sink, but I can’t find any current instructions.
How to implement this in a relatively simple way, so that e.g. a smartphone can connect to it and then distribute music to all SnapCast clients?

Would it also be technically possible to use the Bluetooth adapter from, say, a Raspberry Pi Zero WH connected to an amplifier?
So something like this setup:
Bluetooth → RPi Zero WH → WiFi → SnapCast Server on Pi 4B → LAN/WiFi → SnapCast Clients

The instructions I found are either incomplete or used packages are no longer available. :frowning:

I certainly think it should be possible to run some kind of Bluetooth service on the Pi and connect the output to Snapserver. It looks like you’ve already realised that there’s not any need to involve Mopidy in that setup.

Here’s a link to previous discussion about the subject, with some suggestions.

That is correct.
Just thought that here maybe in the forum someone has already dealt with it and has a solution.

Of course, it would also be extremely cool if the Bluetooth connection could be set via Mopidy.
… With Mopidy accept the pairing or something … :slight_smile:

I realise this is an old thread but I’ve had great success with Cornrow (GitHub - mincequi/cornrow: Bluetooth Audio Daemon for Raspberry Pi) and there are instructions there on integration with Snapcast. You can then choose the source through Mopidy Iris and the Android Snapcast app - probably other means but these are the two I’ve used it with. It’s been rock solid for a long time now.

I did the same on OpenWrt:
Bluetooth → PulseAudio → Snapcast server → …

As of OpenWrt, I had to stick with Pulseaudio (with the -avahi variant), but you could use other alternatives e.g. PipeWire, Arkq/bluez-alsa).

Because the dongle is plugged into the Snapcast server I simply used the module-pipe-sink to pipe the audio to a /tmp/snapfifoa2dp file. :upside_down_face:

For “remote piping” from RPi Zero WH, you could use the tcp server or tcp client audio source.
There are examples for Mopidy for both.

Hi There,

I am trying to achieve something very similar and struggling a lot.
Here is the objective: I want to create basically a wireless audio splitter, where when I play audio through one speaker, it plays through multiple speakers. I dont care about any streaming app, spotify, youtube music, google music, airplay etc. All I want is
my phone to pair to a rpi4b via bluetooth, and then play anything on the phone, like a local mp3 file, youtube, whaterver, and teh audio is received by Rpi4b, then forwarded to snapcast server which then syncs playback on a number of pi3B units running snapcast client, each connected to a cheap speaker via 3.5mm slot.

I figured I dont need mopidy. So was thinking of using pulseaudio to send the audio to snapcast server. Because of my lack of knowledge of pulseaudio implementation in PI4, and snapcast server, I have been struggling with it.

I understand that there needs to be this entity called a “sink” that should capture teh pulseaudio output, and snapcast server will somehow magically consume from this sink. I tried to follow: [Tutorial] How to Stream Audio From your PC to any Device - Tutorials - Manjaro Linux Forum , where the path is :


The first 2 commands work without errors:
pacmd load-module module-pipe-sink file=/tmp/snapfifo sink_name=Snapcast format=s16le rate=48000
pacmd update-sink-proplist Snapcast device.description=Snapcast

Then when I start snapcast server (with default configuration file, no changes):
2023-04-02 03-39-43.418 [Info] (Snapserver) Version 0.27.0, revision 54a3d862
2023-04-02 03-39-43.418 [Info] (Snapserver) Adding source: pipe:///tmp/snapfifo?name=default
2023-04-02 03-39-43.420 [Notice] (init) Settings file: “/home/fyelabs/.config/snapserver/server.json”
2023-04-02 03-39-43.422 [Info] (Snapserver) Using HTTP host name: spaudio
2023-04-02 03-39-43.439 [Info] (Avahi) Adding service ‘Snapcast’
2023-04-02 03-39-43.450 [Info] (PcmStream) PcmStream: default, sampleFormat: 48000:16:2
2023-04-02 03-39-43.450 [Info] (PipeStream) PipeStream mode: create
2023-04-02 03-39-43.450 [Info] (Server) Stream: {“fragment”:“”,“host”:“”,“path”:“/tmp/snapfifo”,“query”:{“chunk_ms”:“20”,“codec”:“flac”,“name”:“default”,“sampleformat”:“48000:16:2”},“raw”:“pipe:////tmp/snapfifo?chunk_ms=20&codec=flac&name=default&sampleformat=48000:16:2”,“scheme”:“pipe”}
2023-04-02 03-39-43.451 [Info] (FlacEnc) Init - compression level: 2
2023-04-02 03-39-43.452 [Info] (ControlServer) Creating TCP acceptor for address: 0.0.0.0, port: 8081
2023-04-02 03-39-43.452 [Info] (ControlServer) Creating HTTP acceptor for address: 0.0.0.0, port: 8080
2023-04-02 03-39-43.452 [Info] (StreamServer) Creating stream acceptor for address: 0.0.0.0, port: 8082
2023-04-02 03-39-43.453 [Info] (Snapserver) Number of threads: 4, hw threads: 4
2023-04-02 03-39-44.502 [Info] (Avahi) Service ‘Snapcast’ successfully established.

So it starts. I can use a snapcast client app on my phone and can actually see the snapcast server. HOwever, when I play some audio on my pi4b locally, say a mp3 file using vlc, it plays through the local sink, and audio comes out of the speakers connected at 3.5 mm slot instead of teh newly created snapcast sink.

I confirmed teh sink was created and when I pared bluetooth with my phone, na dplayed some youtube stuff on my phone, the audio came out from teh pi4b speakers and the wrong sink:
0 alsa_output.platform-bcm2835_audio.analog-stereo module-alsa-card.c s16le 2ch 44100Hz RUNNING
1 alsa_output.platform-3f902000.hdmi.hdmi-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
2 Snapcast module-pipe-sink.c s16le 2ch 48000Hz SUSPENDED

I guess since the audio is not getting routed through the snapcast sink, it never makes it to snapcast server, and therefore to none of teh clients. I am lost at this point in terms of whts should be teh next step. I feel this should have been an extremely simple setup, but probably becasue of my lack of knowledge, its turning out to be very frustrating. Can anyone help me out with more detailed instructions on how to make teh system work? I belive teh article I was following assumed advanced level users, and did not probably provide additional instructions on how to route audio through teh newly created sink.

Any help will be much appreciated.

Thanks

Have now found some time again to take care of the project.
Unfortunately I don’t get very far.

I clicked through your links and did some research.
Probably the “best” way is to intercept the bluetooth interface via PulaseAudio and make it available via a tcp-stream snapcast.
Problem here is that I can’t manage to send the input from Bluetooth to the TCP stream.
I have no idea what the correct configuration is.
Examples from the Internet unfortunately do not work.

With the help of this script (GitHub - nicokaiser/rpi-audio-receiver: Raspberry Pi Audio Receiver with Bluetooth A2DP, AirPlay, and Spotify Connect) I managed to set up Bluetooth very easily so that devices can connect.
However, the output is only local to the Raspberry Pi.

Has anyone made any progress here?

I tried Cornrow, but that no longer works good with Debian 11 (which the latest Raspberry OS is based on).
Also, the Android app is not compatible with Android 13.
Too bad, probably would have been too easy with that too.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.