BalenaSound audio delay

Hi, I’ve managed to get working the multi room audio feature but the audio between the two have a little bit of delay…
I’ve got two Raspberry Pi 3b, one connected via aux to the speakers and one connected to a Samsung TV which is connected to another speakers.
Is there a way to manually adjust the delay/sync time?

Thanks in advance.

Hello there, welcome to the forums and thanks for trying out balenaSound!

Do you mean one device playing sound is lagging a bit when compared with the other one?

Yes, one of the two is a little bit delayed backwards…

Okay, thanks. So to sync audio across devices we use SnapCast which has a typical deviation of less than 0.2ms. SnapCast is extremely stable so it’s not very likely that software is at fault here. For starters, make sure you are using balenaSound version 2.0.5 or later, we updated snapcast to it’s latest version on that patch so that will ensure you are up to date.

What I suspect the problem to be here is the differences in audio processing after it goes out of the Pi and into the speakers. Particularly, the TV I think probably has audio circuitry or additional processing that is making it out of sync. The snapclient has an option to compensate for this, support for it is not included in balenaSound at the moment, but I just created a branch you can check out: https://github.com/balenalabs/balena-sound/tree/snapclient-latency

Note that this is not tested as I can’t replicate the hardware out-of-syncing thing, but if you are up for testing it, this is what you need to do:

  1. Download the updated code in https://github.com/balenalabs/balena-sound/tree/snapclient-latency
  2. Push the new branch to your devices using balena push <appName>, or using git, same as you did the first time.
  3. Go to the balena dashboard, to the device that you think is behind (so the one that is late or more delayed) and add a Device environment variable (Device variables on the side bar) called DEVICE_LATENCY and assign it a value in msec. The exact value you will need to find out for yourself empirically, I suggest starting with 100 and go from there.
  4. Wait for device reboot, and test again. You might have to adjust the latency value a couple of times until you find one that works.

If this does work please let us know so that we can push this changes into the master branch and make balenaSound more awesome!

On step 3 make sure you define the variable only for the device you see lagging. If you define the variable from the application screen you will most likely do it fleet-wide which won’t be of use :stuck_out_tongue:

Wow, thanks a lot.
I will absolutely give it a try. :star_struck:

O.T.:
Is there a way to emulate a second Raspberry Pi 3b on a pc or to install BalenaOS on a x64 pc?

Hey there!
You can take a look at this blog post about how to Use VirtualBox to simulate a device for balenaCloud in order to emulate a device.
It’s possible to install balenaOS on the laptop directly since we have the new Generic x86_64 device type for that, but notice that this is something that will wipe your entire internal storage.
What you could also try is to Run balenaOS as a docker container