Clicking sound while connecting USB audio card directly to HA server and Sample rate

Need some community assistance with audio.
I’m using hass os in Proxmox environment. I’ve connected USB audio card to server and attached it to HA container, in HA cli I can see this USB card and using vlc-telnet addon even can use this card as output device, but sound is not clear, it always “clicking”.
I’ve tested 2 different audio cards / DAC, different speakers and amplifiers and at the end found that problem is not in hardware.

It seems that problem in sampling rate, coz I’ve tested the same usb devices in ubuntu and got the same “clicking” result, then I’ve make small tune for /etc/pulse/daemon.conf (in test Ubuntu) and added
default-sample-rate = 48000
alternate-sample-rate = 48000

after this tweak sound became clear from both USB cards.
So my question is - how to make this tweak in HA so it will not be overwritten after restart.
Or maybe I’m on a wrong way and there is aby better way how to connect USB audio card to HA and use it as output media device

Did you figure out a way to do this? I’m having the same issue with my Kanto Yu2 speakers.

not yet, still searching for a solution

as a temporary solution we could modify daemon.conf manually and restart audio (but we need to do it each time ha restarts).
Not the best way, but works if you did not restart server too often. possible to add somewhere to start after ha starts, but did not found such place, coz from shell_command docker command not available

docker exec -it hassio_audio sed -i '/; default-sample-rate = 44100/c\default-sample-rate = 48000' /etc/pulse/daemon.conf
ha audio restart
1 Like

anyone with a solution? I have this issue with a Anker USB audio device (speaker and mic) connected to my HA Yellow and can’t get audio out without it popping and clicking :frowning:

see Reddit - Dive into anything

The above docker command does not work on the Yellow HW with HA OSS

Doesn’t the Yellow also start docker containers?
@astraliens’ docker command is simply changing the default sample-rate in the audio-config of HA.

Please try the longer way by utilizing the SSH-Terminal and look if that works for you.

Attention: You have to disable the “safe mode” of the SSH-Terminal to be able to work with docker in HA. Go to the SSH-Termina-Addon-settings, disable the safe mode and restart the addon.

Find the audio / Pulseaudio docker container id:

docker ps | grep "audio"

Edit the daemon.conf:

docker exec -it <enter hassio-audio docker id here> vi /etc/pulse/daemon.conf


Insert your new config at the end. Work with the PulseAudio docs to identify which is important for you.

I added this:

default-sample-format = s24le
default-sample-rate = 48000
alternate-sample-rate = 96000
resample-method = soxr-vhq
avoid-resampling = yes

It will enable the sample depth at 24bit, the default sample rate at 48khz but will allow media played at 96khz.
soxr-vhq is the best resampling quality but might produce high cpu load.
“Avoiding the resampling” enforces the hardware to play at the specified sample rates if it supports it.

Additionally you can check which sound card profile is used and possibly select a more suitable:

ha audio info

In my case the correct one is already selected but maybe you have other options.

Finish with

ha audio restart

is there a permanent fix for this? same issue USB audio card