Strange crackles with bluetooth audio on Pi Zero W

I’ve set up Mopidy on a Pi Zero W using the latest Raspbian lite image. I was hoping to play audio through Bluetooth using bluealsa. When I run mopidy from the command line as a normal user it works fine, but when I run Mopidy as a service I get crackles, pops, and dorpouts in the audio. The CPU usgae never goes above 25%.

I changed the service file to run Mopidy as the user I log in as, instead of ‘mopidy’ and this has made things significantly better but not entirely. Anybody got any ideas?

I think there is a priority difference when running things as the currently logged in user vs a system account. I can’t now find the article I was looking for on the subject but can you try playing with the cgroup limits that systemd uses when running the service? Also perhaps share the output of top and/or systemd-cgtop. I don’t have any useful experience with bluealsa so I can’t offer anything specific to that.

And also maybe try setting a different cpu scheduler? I don’t remember what the raspbian default is:

echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

Thanks for that reply. It looks like there were two things going on - the main one being that the Pi WiFi and Bluetooth interfere with one another. It was that that was causing the noise. There’s now a fix for that, and the noise has gone. I can’t explain why it was worse when running as a service, but further experimentation showed that it wasn’t perfect running from a console either.

I guess we can mark this as solved.

What’s the fix for that? Something already now in latest Raspbian or something manual?

There are some NVRAM changes detailed near the bottom of this thread

which can be applied manually but will soon be in Raspbian.