Delay balena sound/snapcast

Hello all
First of all, thanks for this great product! Balena sound is incredible
I have balena running on a raspberry pi 4 and use snapcast on old android smartphone to do multi room.
But I can hear that somehow the music is not playing exactly at the same time.
If I put 2 devices on snapcast they would be synchro but not with the raspberry…
What would you advice?
Thanks a lot

Ps: hope I’m posting in the right section

Hi

Welcome to the forums, and it’s great to know that you find balena sound useful!

Have you checked our troubleshooting guide for some of the common issues folks face? If so, what did you try from the suggestions, and what were the results?

already looked at the troubleshooting guide and did not find what I was looking for. Because I need multi room…
Is it possible the delay comes from the fact that the rapsberry outputs the sounds directly from the spotify connect and that my other devices play from the snapcast server ?
Can the raspberry output the sound from the snapcast server (enable snapcast client on the raspberry)
Thanks for your help

Hi there, thanks for the kind words about balenaSound, I’m a project maintainer and developer so it means a lot!

If I understand correctly, what you want to do is to sync your Pi running balenaSound to a Snapcast server that’s running on a device which does not run balenaSound, is this correct? If so, extra points for the novel setup!

You can configure your balenaSound device to connect to any Snapcast server by using the environment variable SOUND_MULTIROOM_MASTER, this should be enough I believe. So if your server has IP address 192.168.1.123 then you’ll need to do SOUND_MULTIROOM_MASTER=192.168.1.123. You can check balenaSound docs and balena docs for details on how to work with env vars if you are not familiar with them.

Let me know if this helps or if I completely misunderstood your setup and question (hehe).

Nope this is not what I meant.
Balena sound runs on my pi.
On android phone I connect using snapcast app, to the pi (so snapcast server from balenaSound)
There is a delay between my pi and the Android phones
I was wondering how to solve this.
Is it clearer?

Does it make sense to try to set the environment variable SOUND_MULTIROOM_MASTER towards the pi IP and see if it’s better? Or is it pointless as it’s already the master by default

By the way, I have on my internet provider box the possibility to install virtual machines (by default Ubuntu 19.04, Ubuntu 19.10, Debian, Fedora 30, Jeedo). I use it for instance to run a PLEX server which is working great
I tried flashing my raspberry image (balena-cloud-balena-sound-raspberrypi4-64-2.69.1+rev1-v12.3.5) and change the parameters when generating the image to ethernet only, but it doesn’t seem to connect.
How could I solve this from the console?
(I also flash a new NUC image trying to adapt that tutorial No hardware? Use VirtualBox to simulate a device for balenaCloud! but same result not connecting)

Below is a screenshot of what I get when it finnaly loads ( i get start pxe over ipv4 error at the beggining)

Hi, just so I understand, you’re playing music through your android phone connected directly to a speaker while also broadcasting that sound to the pi?

yes basically the pi with balena sound receives music from spotify connect and broadcast on the network. Various android phones receive the music using snapcast app and play on different soundsystem in different parts of the apartment.
All the android phones seems to be more or less syncronized. The pi (connecting directly on the pi 4 jack) is not syncronized with them

Hey there, regarding your VM on your gateway device, I would suggest using the Generic x86_64 device image for maximum compatibility. It has more drivers preinstalled than the NUC image. Do you know for sure that the gateway device is x86_64
or is it ARM?

Regarding the synchronized playback, would I be correct in assuming that the android phones are slightly delayed compared to the RPI audio out jack?

If this is the case, then I would attribute it to the intentional latency of the snapcast server keeping the phones in sync is what also makes the RPI audio jack playback appear to be ahead of the phones by a few seconds. It’s much faster for the balenaSound server to put audio over the RPI jack than it is for the snapcast server to synchronize multiple android devices I would think.

Hi, thanks for your answer
The VM is running on a box powered by an ARMv8 Armada 8040.
About the delay it’s almost nothing I believe less than a second so difficult to say which one is first but I was thinking the same as you. That’s why I asked if it was possible to get on the jack of the pi the sound from the client rather than directly the pi (even if the pi is also the server)

Regarding the VM, you could try using the Generic AARCH64 image, but ARM platforms tend to be very hardware specific so your mileage may vary. Keep in mind that by putting balenaOS in a VM we will require certain kernel features to be enabled, and need to run with elevated permissions in order to create mounts, etc.

Hi there, have you considered tweaking SOUND_INPUT_LATENCY and/or SOUND_OUTPUT_LATENCY parameters as per the docs? These parameters drive the loopback pulseaudio module and can insert a static latency, which you will have to tune to your specific environment. Hopefully the latency is fairly static, so one you pick something that works, it should continue working.

I was hoping to avoid this one, but could be a good alternative solution
Thanks