ralph-irving / squeezelite

Lightweight headless squeezebox player for Lyrion Media Server
https://sourceforge.net/projects/lmsclients/files/squeezelite/
Other
387 stars 98 forks source link

Squeezelite & pipewire - buffer size #170

Open mervinbeng opened 1 year ago

mervinbeng commented 1 year ago

I use squeezelite on an arch linux system (6.0.2 kernel) and have observed this issue for some time, but could not identify that it was squeezelite-related. I now believe that it is quite likely:

By default squeezelite's buffer of 40msec in a pipewire-pulse environment. Using this default buffer I find the buffer (pipewire "quantum") is 441 when sample rate is 44100Hz. This is not a good factor of 2^n (like 256 or 512 ..) and when starting up I often here a high-pitched squeal. Occasionally I will hear this squeal mid-stream when playing music.

When I start up with -a 4096:4 or 8192:4, the quantum as seen on pw-top is 1024 or 2048, and the program start without this high-pitched squeal.

It has taken a long time to trace this issue, and so far it appears that keeping to a buffer which forces squeezelite to use a multiple of 256 seems to reduce occasional noise. In addition the output sounds clearer (but this is purely subjective). Perhaps if the output is pipewire:, squeezelite should adjust the buffer size to a power of 2? 441 or 882 or 480 don't seem to make sense here.

th2j commented 11 months ago

Why do you need Pipewire ? What is you sound card ? Can you use ALSA instead ? There will be a more direct patch between Squeezelite and the sound card

mervinbeng commented 11 months ago

Thanks for checking. The squeezelite needs to feed to pipewire-pulse because it's part of an HTPC setup, including digital EQ. The TV, squeezelite and other devices all feed a common sink.

With more recent releases of pipewire, things are now quite glitch-free.

On Tue, 31 Oct 2023, 4:12 pm th2j, @.***> wrote:

Why do you need Pipewire ? What is you sound card ? Can you use ALSA instead ? There will be a more direct patch between Squeezelite and the sound card

— Reply to this email directly, view it on GitHub https://github.com/ralph-irving/squeezelite/issues/170#issuecomment-1786709606, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGCSBISAAEXFAYWTPHXIG23YCCXGNAVCNFSM6AAAAAARMV2UYKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBWG4YDSNRQGY . You are receiving this because you authored the thread.Message ID: @.***>

th2j commented 11 months ago

maybe it isn't link to the use of multiple of 256 maybe the glitch disappears because you use higher buffers have you tried 400:4 instead of 40:4 ?