Bug 105714 - Fast volume change (using keyboard key) causes volume difference between channels
Summary: Fast volume change (using keyboard key) causes volume difference between chan...
Status: RESOLVED MOVED
Alias: None
Product: PulseAudio
Classification: Unclassified
Component: alsa (show other bugs)
Version: unspecified
Hardware: All Linux (All)
: medium minor
Assignee: pulseaudio-bugs
QA Contact: pulseaudio-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-03-23 15:17 UTC by Hilary Jendrasiak
Modified: 2018-07-30 10:18 UTC (History)
2 users (show)

See Also:
i915 platform:
i915 features:


Attachments
Screen capture with `pavucontrol` and `screenkey`. (5.12 MB, video/mp4)
2018-03-23 15:17 UTC, Hilary Jendrasiak
Details

Description Hilary Jendrasiak 2018-03-23 15:17:36 UTC
Created attachment 138315 [details]
Screen capture with `pavucontrol` and `screenkey`.

I've custom keybind in
/etc/xdg/openbox/rc.xml
It is:

  <keybind key="XF86AudioLowerVolume">
    <action name="Execute">
      <startupnotify>
        <enabled>true</enabled>
        <name>LowerVolume</name>
      </startupnotify>
      <command>amixer -D pulse sset Master 1%-</command>
    </action>
  </keybind>

(Analogical 1%+)

In my keyboard the XF86AudioLowerVolume can be triggered by rotating keyboard's volume control winder. And the winder is ok.

As long as I'm rotating this winder slow – everything is ok. The problem occurs when I'm sending more than c.a. 10 XF86AudioLowerVolume "presses" per second. (That's not so many – less than 180° rotation! That winder is standard "infinite" rotation winder. Nothing special.)

I've prepared simple bash script that can simulate spinning of winder volume control. For me it's working just as bad as fast winder rotation.
https://pastebin.com/hR4UCjjJ


(Take care about that I've muted STDOUT and STDERR in loop)
Comment 1 Tanu Kaskinen 2018-03-24 06:57:45 UTC
Thanks for the well-prepared report!

I can reproduce the problem with the script. amixer doesn't seem to set all channels in one go. I'm not sure if that's the fault of amixer or alsa's pulse plugin.

If you change the command to "pactl set-sink-volume @DEFAULT_SINK@ -1%", I would expect the sync problems to disappear. "@DEFAULT_SINK@" is a special string for referring to the default sink, so you don't have to figure out the sink name yourself.
Comment 2 Hilary Jendrasiak 2018-03-25 12:53:46 UTC
(In reply to Tanu Kaskinen from comment #1)
> Thanks for the well-prepared report!
> 
> I can reproduce the problem with the script. amixer doesn't seem to set all
> channels in one go. I'm not sure if that's the fault of amixer or alsa's
> pulse plugin.
> 
> If you change the command to "pactl set-sink-volume @DEFAULT_SINK@ -1%", I
> would expect the sync problems to disappear. "@DEFAULT_SINK@" is a special
> string for referring to the default sink, so you don't have to figure out
> the sink name yourself.

Yes, `pactl set-sink-volume @DEFAULT_SINK@ -1%` is working fine, thanks!

Small warning for everyone who will use it – this method allows you to change volume to 150% (not only to 100%, like `amixer` method). Take care about that and don't burn your amplifier by fast volume incrementing ;)
Comment 3 Hilary Jendrasiak 2018-03-25 16:29:57 UTC
(In reply to Hilary Jendrasiak from comment #2)
> (In reply to Tanu Kaskinen from comment #1)
> > Thanks for the well-prepared report!
> > 
> > I can reproduce the problem with the script. amixer doesn't seem to set all
> > channels in one go. I'm not sure if that's the fault of amixer or alsa's
> > pulse plugin.
> > 
> > If you change the command to "pactl set-sink-volume @DEFAULT_SINK@ -1%", I
> > would expect the sync problems to disappear. "@DEFAULT_SINK@" is a special
> > string for referring to the default sink, so you don't have to figure out
> > the sink name yourself.
> 
> Yes, `pactl set-sink-volume @DEFAULT_SINK@ -1%` is working fine, thanks!
> 
> Small warning for everyone who will use it – this method allows you to
> change volume to 150% (not only to 100%, like `amixer` method). Take care
> about that and don't burn your amplifier by fast volume incrementing ;)

According to amplifier safety issue – here's very simple blocker that should not allow `pactl` to increase volume over 100%. For me it's working, but there is obviously no warranty that it'll work for you, or – in worst case – that it'll not stop protecting you without reason and any notice! (But I hope will be good)

if [ "$(amixer get Master | tail -n1 | cut -d '[' -f 2 | cut -d '%' -f 1)" -lt "100" ]
then
pactl set-sink-volume @DEFAULT_SINK@ +1%
fi
Comment 4 GitLab Migration User 2018-07-30 10:18:56 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/335.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.