Balenasound bluetooth latency -- fixable?

Transmitting sound from my Linux laptop to Balenasound on a RPi3+ via bluetooth, I have about 2 seconds latency.

I read on another forum that this is because of the time to A2DP encode the sound on my laptop, but if that’s the case, why is there no latency when I use portable Bluetooth speakers with my laptop?

If that’s the issue, would it be possible, I wonder, to omit A2DP in cases where sync is more important to me than fidelity?

(Apologies if I’m posting this in the wrong forum category; I took my best guess.)

Hello, from my understanding its not really possible to avoid A2DP as it is used to transmit audio over bluetooth, however Im not sure if there is a lower quality protocol to fallback in case of latency. I asked the balena sound team more information about this and will get back to you as soon as I hear from them. In the meantime I would be curious to know if you experience a comparable delay when transmitting audio from a different device (e.g. a phone to balena-sound)

Thanks. Yes, I tried transmitting from an Android phone and I get the same delay. There is no delay when transmitting from either of these devices to a separate Bluetooth speaker.

Hi @eater – thanks for the additional detail. Can you try the troubleshooting steps outlined here and let us know if that makes a difference?

All the best,

Thanks. I disabled the multiroom default as that page suggests and that improves the latency a little bit, from about 2 seconds to about 1.2 seconds.

Do you think it’s a lost cause to try to get it closer to zero?

I’m no expert but it might be difficult to get it lower. It might be possible to tweak some of the A2DP configuration or use a different lower latency codec, but none of us have had much experience with that. I have pinged the core maintainers of balenaSound to weigh in here and perhaps they will have better ideas than I do :slight_smile:

Hi there, balenaSound maintainer here. Currently there is not much else we can do with regads to the latency, mostly due to limitations of the bluetooth stack we are using for this project. Can I ask what value of --pcm-buffer-time you are using?

I can tell you though that the next major release of balenaSound (3.0) will hopefully address this. It’s still in very early stages, but the results so far are very promising with pretty much no latency.

Thanks, I’ll look forward to 3.0!

Where would I look to find that --pcm-buffer-time number for you?

Hi again - the --pcm-buffer-time is set in the bluetooth-audio/ file - so if you haven’t changed that, it will be the default of 1000000. I’ve not played with trying to reduce latency myself, so I don’t know what you might try setting it to - but you could experiment and let us know if it helps at all.


That certainly seems to be the parameter in question! I cut it from 1000000 to 10000 and latency dropped accordingly, down to a couple dozen ms.

I figure there’s a downside in terms of stream stability? but I’ll keep tweaking it.

Hey - yeah it will be a tradeoff between the stability of the audio stream and it’s latency. You’re forging a path here, so we’d be glad to hear what you find. If you think that a lower setting works better, we may either change the default or add your findings to our troubleshooting page.

Thanks for getting back to us!

Been streaming for 30 minutes now on the 10000 setting with no hiccups. I made it an environment variable so I can adjust as needed – maybe that would be helpful for others.

What was the name of the environment variable you added? Thanks.