Ubuntu – I hear clicks whenever the volume of some audio stream is adjusted

pulseaudiosoundvolume-control

(Almost) whenever the volume of an audio stream is adjusted, I hear a clicking sound.

I was using a web application that emitted multiple streams and adjusted their volume frequently (and should be able to do this), which resulted in an unbearable amount of clicks. (This application has now changed its way of handling streams such that the phenomenon does not occur anymore; the problem can still be reproduced by manually adjusting streams and may be of interest for other applications.)

Is there a known way to prevent this?

Some further observations:

  • This also happens when I adjust the volume of streams manually (with pavucontrol). In particular, this also works for streams from other applications (like ogg123), so it does not seem to be a problem of the application.

  • This does not happen if change the volume of an entire output device, just with the streams on pavucontrol’s playback tab.

  • The intensity of the click depends on the volume of the sound currently playing in the respective audio stream. It can be best heard with monotonous sounds. The phenomenon is also more prominent if at least one other audio stream is played.

  • The phenomenon is also observable for slight volume changes.

  • This is not the same as the problem described in: How can I disable the "popping" sound when adjusting the volume? The sound is clearly distinct from /usr/share/sounds/freedesktop/stereo/audio-volume-change.oga.

  • I have the impression that some update in the last months improved the situation, but did not fully remove the problem. This may also be due to me being an unreliable detector.

  • I first encountered this issue in 14.04. It persists in 16.04.

  • This happens on multiple machines, so I assume that this is not a hardware problem. They are both Intel devices, however. Here is the output of sudo lshw -C multimedia:

    First machine:

    description: Audio device
    product: 7 Series/C210 Series Chipset Family High Definition Audio Controller
    vendor: Intel Corporation
    physical id: 1b
    bus info: pci@0000:00:1b.0
    version: 04
    width: 64 bits
    clock: 33MHz
    capabilities: pm msi pciexpress bus_master cap_list
    configuration: driver=snd_hda_intel latency=0
    resources: irq:28 memory:f2530000-f2533fff
    

    Second machine

    description: Audio device
    product: 82801JI (ICH10 Family) HD Audio Controller
    vendor: Intel Corporation
    physical id: 1b
    bus info: pci@0000:00:1b.0
    version: 00
    width: 64 bits
    clock: 33MHz
    capabilities: pm msi pciexpress bus_master cap_list
    configuration: driver=snd_hda_intel latency=0
    resources: irq:32 memory:f9ff8000-f9ffbfff
    

Best Answer

You may be hitting latency limits of your hardware when pulse is "busy".

configuration: driver=snd_hda_intel latency=0

There is really no such thing as zero latency. I presume that means sub-millisecond.

Per this https://arunraghavan.net/2013/08/pulseaudio-4-0-and-skype/ Setting the env variable PULSE_LATENCY_MSEC=10 before starting an app. This gives the software 10ms of buffer time if it has more work to do mixing streams.

10ms is still low enough latency unless you are playing live music digital instruments or very fast games.

Related Question