Skip to contentSkip to conversation

amixer: convert percentage into db wrongly

DISCUSSION Elimar Riesebieter 5 participants 12 messages Mar 8, 2012 – Mar 9, 2012 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20120308123632.GA8920@adam-laptop

#1 lore raw

severity 663090 normal
forwarded 663090 [email protected]
thanks

Quoted 61 lines · Adam Lee

Package: alsa-utils
Version: 1.0.25-1
Severity: important

db is not linear, but amixer believe it is.

"amixer get Master" says "Limits: Playback 0 - 74", then everytime I run "amixer -q sset Master 10%-", there is 8db dec.

For example, at first Master is 100% and 0db, both alsamixer and amixer think it is, and after I run "amixer -q sset Master 10%-", both alsamixer and amixer says Master is -8.00db, but alsamixer says it is 72%, amixer says it is 89%.

alsamixer is right, amixer calc and set wrongly.

Several months ago, they both right, and I upgraded, and amixer messed up. Please fix it. Thank you.

FYI, my hardware is:
"HDA-Intel" "Conexant CX20585" "HDA:14f15069,17aa214c,00100302 HDA:14f12c06,17aa2122,00100000" "0x17aa" "0x215e"

-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages alsa-utils depends on:

ii  dialog             1.1-20120215-1
ii  libasound2         1.0.25-2
ii  libc6              2.13-27
ii  libncursesw5       5.9-4
ii  libsamplerate0     0.1.8-3
ii  libtinfo5          5.9-4
ii  linux-sound-base   1.0.23+dfsg-4
ii  lsb-base           3.2+Debian29
ii  module-init-tools  6-1
ii  whiptail           0.52.14-8

Versions of packages alsa-utils recommends:

ii  alsa-base  1.0.23+dfsg-4
ii  pciutils   1:3.1.8-2

alsa-utils suggests no packages.

-- no debconf information

_______________________________________________
Pkg-alsa-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-alsa-devel

Signature · 2 lines
  The path to source is always uphill!
                                -unknown-
#2 lore raw

At Thu, 8 Mar 2012 17:30:02 +0100,

Quoted 24 lines · Elimar Riesebieter

severity 663090 normal
forwarded 663090 [email protected]
thanks

Quoted 16 lines · Adam Lee

Package: alsa-utils
Version: 1.0.25-1
Severity: important

db is not linear, but amixer believe it is.

"amixer get Master" says "Limits: Playback 0 - 74", then everytime I run "amixer -q sset Master 10%-", there is 8db dec.

For example, at first Master is 100% and 0db, both alsamixer and amixer think it is, and after I run "amixer -q sset Master 10%-", both alsamixer and amixer says Master is -8.00db, but alsamixer says it is 72%, amixer says it is 89%.

alsamixer is right, amixer calc and set wrongly.

No, both are correct. You are dreaming too much on the world unified percentage representation :)

The percentage in amixer has nothing to do with dB level. It's just the percentage of the raw value range of that mixer element. Thus showing 89% is correct. It's 10% down from 100% (1% is because of the resolution of the raw values).

Now, alsamixer shows the percentage in a different way. It's explained well in the source code (alsamixer/volume_mapping.c), but not mentioned in the man page, unfortunately.

* The mapping is designed so that the position in the interval is proportional
* to the volume as a human ear would perceive it (i.e., the position is the
* cubic root of the linear sample multiplication factor). For controls with
* a small range (24 dB or less), the mapping is linear in the dB values so
* that each step has the same size visually. Only for controls without dB
* information, a linear mapping of the hardware volume register values is used
* (this is the same algorithm as used in the old alsamixer).

The percentage representation in alsamixer corresponds to this mapping, thus it's neither dB nor linear percent.

Takashi

Quoted 53 lines
Quoted 44 lines

Several months ago, they both right, and I upgraded, and amixer messed up. Please fix it. Thank you.

FYI, my hardware is:
"HDA-Intel" "Conexant CX20585" "HDA:14f15069,17aa214c,00100302 HDA:14f12c06,17aa2122,00100000" "0x17aa" "0x215e"

-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages alsa-utils depends on:

ii  dialog             1.1-20120215-1
ii  libasound2         1.0.25-2
ii  libc6              2.13-27
ii  libncursesw5       5.9-4
ii  libsamplerate0     0.1.8-3
ii  libtinfo5          5.9-4
ii  linux-sound-base   1.0.23+dfsg-4
ii  lsb-base           3.2+Debian29
ii  module-init-tools  6-1
ii  whiptail           0.52.14-8

Versions of packages alsa-utils recommends:

ii  alsa-base  1.0.23+dfsg-4
ii  pciutils   1:3.1.8-2

alsa-utils suggests no packages.

-- no debconf information

_______________________________________________
Pkg-alsa-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-alsa-devel

Signature · 6 lines
  The path to source is always uphill!
                                -unknown-
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#3 lore raw

Bug#663090: [alsa-devel] amixer: convert percentage into db wrongly

Add Vincent in cc, because conky read amixer's result.

Quoted 39 lines · Takashi Iwai
Quoted 12 lines · Adam Lee

Package: alsa-utils
Version: 1.0.25-1
Severity: important

db is not linear, but amixer believe it is.

"amixer get Master" says "Limits: Playback 0 - 74", then everytime I run "amixer -q sset Master 10%-", there is 8db dec.

Quoted 6 lines

For example, at first Master is 100% and 0db, both alsamixer and amixer think it is, and after I run "amixer -q sset Master 10%-", both alsamixer and amixer says Master is -8.00db, but alsamixer says it is 72%, amixer says it is 89%.

alsamixer is right, amixer calc and set wrongly.

No, both are correct. You are dreaming too much on the world unified percentage representation :)

The percentage in amixer has nothing to do with dB level. It's just the percentage of the raw value range of that mixer element. Thus showing 89% is correct. It's 10% down from 100% (1% is because of the resolution of the raw values).

Now, alsamixer shows the percentage in a different way. It's explained well in the source code (alsamixer/volume_mapping.c), but not mentioned in the man page, unfortunately.

* The mapping is designed so that the position in the interval is proportional
* to the volume as a human ear would perceive it (i.e., the position is the
* cubic root of the linear sample multiplication factor). For controls with
* a small range (24 dB or less), the mapping is linear in the dB values so
* that each step has the same size visually. Only for controls without dB
* information, a linear mapping of the hardware volume register values is used
* (this is the same algorithm as used in the old alsamixer).

Quoted 3 lines

The percentage representation in alsamixer corresponds to this mapping, thus it's neither dB nor linear percent.

Hi, Takashi

Thank you for replying. But I still insist this is a bug. Three questions:

1, several months ago, it's OK, both amixer and alsamixer use the human mapping(0-10% and 90%-100% are the same change by a human ear), why not now?

2, conky(Vincent, I mean ${mixer}), some other software, lot of user's scripts use amixer to set or get volume, expecting the human mapping, why change the behavior?

3, alsamixer and amixer use the same dB value, why there is difference in percentage? If alsa-utils developer think the human mapping sucks, why you guys still use it in alsamixer? There is no "both correct", the difference confuses user...

IMO: Any, any human says 10% plus, she or he definitely wants the human mapping. Maybe you developing guys think there is nothing wrong now, but how about think it from the perspective of user?

Please consider about fixing it, at least discuss it in alsa-utils mail list, thank you.

#4 lore raw

Bug#663090: [alsa-devel] amixer: convert percentage into db wrongly

Quoted 64 lines · Adam Lee

Add Vincent in cc, because conky read amixer's result.

Quoted 39 lines · Takashi Iwai
Quoted 12 lines · Adam Lee

Package: alsa-utils
Version: 1.0.25-1
Severity: important

db is not linear, but amixer believe it is.

"amixer get Master" says "Limits: Playback 0 - 74", then everytime I run "amixer -q sset Master 10%-", there is 8db dec.

Quoted 6 lines

For example, at first Master is 100% and 0db, both alsamixer and amixer think it is, and after I run "amixer -q sset Master 10%-", both alsamixer and amixer says Master is -8.00db, but alsamixer says it is 72%, amixer says it is 89%.

alsamixer is right, amixer calc and set wrongly.

No, both are correct. You are dreaming too much on the world unified percentage representation :)

The percentage in amixer has nothing to do with dB level. It's just the percentage of the raw value range of that mixer element. Thus showing 89% is correct. It's 10% down from 100% (1% is because of the resolution of the raw values).

Now, alsamixer shows the percentage in a different way. It's explained well in the source code (alsamixer/volume_mapping.c), but not mentioned in the man page, unfortunately.

* The mapping is designed so that the position in the interval is proportional
* to the volume as a human ear would perceive it (i.e., the position is the
* cubic root of the linear sample multiplication factor). For controls with
* a small range (24 dB or less), the mapping is linear in the dB values so
* that each step has the same size visually. Only for controls without dB
* information, a linear mapping of the hardware volume register values is used
* (this is the same algorithm as used in the old alsamixer).

Quoted 3 lines

The percentage representation in alsamixer corresponds to this mapping, thus it's neither dB nor linear percent.

Hi, Takashi

Thank you for replying. But I still insist this is a bug. Three questions:

1, several months ago, it's OK, both amixer and alsamixer use the human mapping(0-10% and 90%-100% are the same change by a human ear), why not now?

2, conky(Vincent, I mean ${mixer}), some other software, lot of user's scripts use amixer to set or get volume, expecting the human mapping, why change the behavior?

3, alsamixer and amixer use the same dB value, why there is difference in percentage? If alsa-utils developer think the human mapping sucks, why you guys still use it in alsamixer? There is no "both correct", the difference confuses user...

Quoted 6 lines

IMO: Any, any human says 10% plus, she or he definitely wants the human mapping. Maybe you developing guys think there is nothing wrong now, but how about think it from the perspective of user?

Please consider about fixing it, at least discuss it in alsa-utils mail list, thank you.

Sorry for including [email protected] in cc. Please remove it when you reply.

And additional info:

I was searching some alternative way to control my volume, but I failed, every script, evert widget uses "amixer set channel xx%(+/-)", like:
http://awesome.naquadah.org/wiki/Volume_control_and_display

This means "we user want the human mapping, it works well before. and we wrote tons of scripts using amixer and expecting human mapping".

#5 lore raw
In reply to Adam Lee

At Fri, 9 Mar 2012 12:22:47 +0800,

Quoted 47 lines · Adam Lee

Add Vincent in cc, because conky read amixer's result.

Quoted 39 lines · Takashi Iwai
Quoted 12 lines · Adam Lee

Package: alsa-utils
Version: 1.0.25-1
Severity: important

db is not linear, but amixer believe it is.

"amixer get Master" says "Limits: Playback 0 - 74", then everytime I run "amixer -q sset Master 10%-", there is 8db dec.

Quoted 6 lines

For example, at first Master is 100% and 0db, both alsamixer and amixer think it is, and after I run "amixer -q sset Master 10%-", both alsamixer and amixer says Master is -8.00db, but alsamixer says it is 72%, amixer says it is 89%.

alsamixer is right, amixer calc and set wrongly.

No, both are correct. You are dreaming too much on the world unified percentage representation :)

The percentage in amixer has nothing to do with dB level. It's just the percentage of the raw value range of that mixer element. Thus showing 89% is correct. It's 10% down from 100% (1% is because of the resolution of the raw values).

Now, alsamixer shows the percentage in a different way. It's explained well in the source code (alsamixer/volume_mapping.c), but not mentioned in the man page, unfortunately.

* The mapping is designed so that the position in the interval is proportional
* to the volume as a human ear would perceive it (i.e., the position is the
* cubic root of the linear sample multiplication factor). For controls with
* a small range (24 dB or less), the mapping is linear in the dB values so
* that each step has the same size visually. Only for controls without dB
* information, a linear mapping of the hardware volume register values is used
* (this is the same algorithm as used in the old alsamixer).

Quoted 3 lines

The percentage representation in alsamixer corresponds to this mapping, thus it's neither dB nor linear percent.

Quoted 8 lines

Hi, Takashi

Thank you for replying. But I still insist this is a bug. Three questions:

1, several months ago, it's OK, both amixer and alsamixer use the human mapping(0-10% and 90%-100% are the same change by a human ear), why not now?

amixer hasn't been changed until yet. It handles either in raw values or in dB. No human-ear mapping at all. It's never changed since years, and won't be changed. If the volume mapping would be implemented to amixer in future, it must be only optional.

Only the recent alsamixer introduced the volume mapping to visualize the volumes reasonably.

Quoted 3 lines

2, conky(Vincent, I mean ${mixer}), some other software, lot of user's scripts use amixer to set or get volume, expecting the human mapping, why change the behavior?

You must be smoking something bad. The behavior of amixer hasn't been changed.

Quoted 4 lines

3, alsamixer and amixer use the same dB value, why there is difference in percentage? If alsa-utils developer think the human mapping sucks, why you guys still use it in alsamixer? There is no "both correct", the difference confuses user...

That's true. alsamixer should have stopped showing the stupid percentage.

The biggest understand is that people (including you) think there is an absolutely perfect percentage definition for the sound level. It's an illusion.

Quoted 6 lines

IMO: Any, any human says 10% plus, she or he definitely wants the human mapping. Maybe you developing guys think there is nothing wrong now, but how about think it from the perspective of user?

Please consider about fixing it, at least discuss it in alsa-utils mail list, thank you.

There is no such ML...

Takashi

#6 lore raw

Bug#663090: [alsa-devel] amixer: convert percentage into db wrongly

Quoted 58 lines · Takashi Iwai

At Fri, 9 Mar 2012 12:22:47 +0800,

Quoted 47 lines · Adam Lee

Add Vincent in cc, because conky read amixer's result.

Quoted 39 lines · Takashi Iwai
Quoted 12 lines · Adam Lee

Package: alsa-utils
Version: 1.0.25-1
Severity: important

db is not linear, but amixer believe it is.

"amixer get Master" says "Limits: Playback 0 - 74", then everytime I run "amixer -q sset Master 10%-", there is 8db dec.

Quoted 6 lines

For example, at first Master is 100% and 0db, both alsamixer and amixer think it is, and after I run "amixer -q sset Master 10%-", both alsamixer and amixer says Master is -8.00db, but alsamixer says it is 72%, amixer says it is 89%.

alsamixer is right, amixer calc and set wrongly.

No, both are correct. You are dreaming too much on the world unified percentage representation :)

The percentage in amixer has nothing to do with dB level. It's just the percentage of the raw value range of that mixer element. Thus showing 89% is correct. It's 10% down from 100% (1% is because of the resolution of the raw values).

Now, alsamixer shows the percentage in a different way. It's explained well in the source code (alsamixer/volume_mapping.c), but not mentioned in the man page, unfortunately.

* The mapping is designed so that the position in the interval is proportional
* to the volume as a human ear would perceive it (i.e., the position is the
* cubic root of the linear sample multiplication factor). For controls with
* a small range (24 dB or less), the mapping is linear in the dB values so
* that each step has the same size visually. Only for controls without dB
* information, a linear mapping of the hardware volume register values is used
* (this is the same algorithm as used in the old alsamixer).

Quoted 3 lines

The percentage representation in alsamixer corresponds to this mapping, thus it's neither dB nor linear percent.

Quoted 8 lines

Hi, Takashi

Thank you for replying. But I still insist this is a bug. Three questions:

1, several months ago, it's OK, both amixer and alsamixer use the human mapping(0-10% and 90%-100% are the same change by a human ear), why not now?

Quoted 8 lines

amixer hasn't been changed until yet. It handles either in raw values or in dB. No human-ear mapping at all. It's never changed since years, and won't be changed. If the volume mapping would be implemented to amixer in future, it must be only optional.

Only the recent alsamixer introduced the volume mapping to visualize the volumes reasonably.

OK, thank you. Maybe an optional will make everyone happy.

Quoted 7 lines
Quoted 3 lines

2, conky(Vincent, I mean ${mixer}), some other software, lot of user's scripts use amixer to set or get volume, expecting the human mapping, why change the behavior?

You must be smoking something bad. The behavior of amixer hasn't been changed.

I figured out a reason probably, when the limits range is wide, like 0-65536, amixer's mapping and alsamixer's human-ear mapping are close.

If I remember right, my hardware's limits was 0-65536, but it becomes 0-74 after I run "alsactl init", but unfortunately, I don't know how to modify it back.

Quoted 5 lines
Quoted 4 lines

3, alsamixer and amixer use the same dB value, why there is difference in percentage? If alsa-utils developer think the human mapping sucks, why you guys still use it in alsamixer? There is no "both correct", the difference confuses user...

Quoted 7 lines

That's true. alsamixer should have stopped showing the stupid percentage.

The biggest understand is that people (including you) think there is an absolutely perfect percentage definition for the sound level. It's an illusion.

I don't expect an absolutely perfect percentage definition. I want a human-ear mapping, which alsamixer does well, 100% is about as ten times loud as 10%. But amixer doesn't work like that, amixer's 100% is about as *one hundred times* as amixer's 10%.

Maybe it is beautiful, and alsamixer's human-ear mapping is stupid in the sound science universe. But as a common user, I don't think so. And I don't know how you guys put up with it :(

Quoted 9 lines
Quoted 6 lines

IMO: Any, any human says 10% plus, she or he definitely wants the human mapping. Maybe you developing guys think there is nothing wrong now, but how about think it from the perspective of user?

Please consider about fixing it, at least discuss it in alsa-utils mail list, thank you.

There is no such ML...

OK, thank you all the same.

#7 lore raw

At Fri, 9 Mar 2012 17:07:17 +0800,

Quoted 94 lines · Adam Lee
Quoted 58 lines · Takashi Iwai

At Fri, 9 Mar 2012 12:22:47 +0800,

Quoted 47 lines · Adam Lee

Add Vincent in cc, because conky read amixer's result.

Quoted 39 lines · Takashi Iwai
Quoted 12 lines · Adam Lee

Package: alsa-utils
Version: 1.0.25-1
Severity: important

db is not linear, but amixer believe it is.

"amixer get Master" says "Limits: Playback 0 - 74", then everytime I run "amixer -q sset Master 10%-", there is 8db dec.

Quoted 6 lines

For example, at first Master is 100% and 0db, both alsamixer and amixer think it is, and after I run "amixer -q sset Master 10%-", both alsamixer and amixer says Master is -8.00db, but alsamixer says it is 72%, amixer says it is 89%.

alsamixer is right, amixer calc and set wrongly.

No, both are correct. You are dreaming too much on the world unified percentage representation :)

The percentage in amixer has nothing to do with dB level. It's just the percentage of the raw value range of that mixer element. Thus showing 89% is correct. It's 10% down from 100% (1% is because of the resolution of the raw values).

Now, alsamixer shows the percentage in a different way. It's explained well in the source code (alsamixer/volume_mapping.c), but not mentioned in the man page, unfortunately.

* The mapping is designed so that the position in the interval is proportional
* to the volume as a human ear would perceive it (i.e., the position is the
* cubic root of the linear sample multiplication factor). For controls with
* a small range (24 dB or less), the mapping is linear in the dB values so
* that each step has the same size visually. Only for controls without dB
* information, a linear mapping of the hardware volume register values is used
* (this is the same algorithm as used in the old alsamixer).

Quoted 3 lines

The percentage representation in alsamixer corresponds to this mapping, thus it's neither dB nor linear percent.

Quoted 8 lines

Hi, Takashi

Thank you for replying. But I still insist this is a bug. Three questions:

1, several months ago, it's OK, both amixer and alsamixer use the human mapping(0-10% and 90%-100% are the same change by a human ear), why not now?

Quoted 8 lines

amixer hasn't been changed until yet. It handles either in raw values or in dB. No human-ear mapping at all. It's never changed since years, and won't be changed. If the volume mapping would be implemented to amixer in future, it must be only optional.

Only the recent alsamixer introduced the volume mapping to visualize the volumes reasonably.

OK, thank you. Maybe an optional will make everyone happy.

Quoted 7 lines
Quoted 3 lines

2, conky(Vincent, I mean ${mixer}), some other software, lot of user's scripts use amixer to set or get volume, expecting the human mapping, why change the behavior?

You must be smoking something bad. The behavior of amixer hasn't been changed.

I figured out a reason probably, when the limits range is wide, like 0-65536, amixer's mapping and alsamixer's human-ear mapping are close.

If I remember right, my hardware's limits was 0-65536, but it becomes 0-74 after I run "alsactl init", but unfortunately, I don't know how to modify it back.

Quoted 8 lines
Quoted 4 lines

3, alsamixer and amixer use the same dB value, why there is difference in percentage? If alsa-utils developer think the human mapping sucks, why you guys still use it in alsamixer? There is no "both correct", the difference confuses user...

That's true. alsamixer should have stopped showing the stupid percentage.

Quoted 8 lines
Quoted 4 lines

The biggest understand is that people (including you) think there is an absolutely perfect percentage definition for the sound level. It's an illusion.

I don't expect an absolutely perfect percentage definition. I want a human-ear mapping, which alsamixer does well, 100% is about as ten times loud as 10%.

How did you measure _quantitatively_ it's exactly ten times louder? And you think 50% is ten times loud as 5% volume, 10% is ten times loud as 1%? Things aren't so easy, unfortunately.

Quoted 2 lines

But amixer doesn't work like that, amixer's 100% is about as *one hundred times* as amixer's 10%.

Yes, this is what's amixer expected to behave. It's a value just representing the percentage of a "raw value" of the mixer element. It never says it's corresponding to any practical volume. This is the misunderstanding first of all.

For example, I guess in your 64k case, the raw value is even not in dB unit but it's a linear volume. amixer doesn't care. 10% means only the 6553 of 65536. That's all. So simple.
(In addition, amixer can handle dB, e.g. amixer set Master +10dB or
such. But it's not suitable for percentage unit because dB level can't be represented in the absolute percent volume -- what is 10% in dB?)

Quoted 3 lines

Maybe it is beautiful, and alsamixer's human-ear mapping is stupid in the sound science universe. But as a common user, I don't think so. And I don't know how you guys put up with it :(

No, you misunderstand what I wrote. alsamixer's mapping is really an improvement. That's why it was implemented recently. But if it shows a different number, user may wonder, just like you did. If you didn't see a number, you didn't notice the difference :)

But amixer wasn't changed. amixer is a tool to manipulate raw values. Of course, it'd be also nice to implement the same percentage expression, but as already mentioned, it should be activated only via an option. The default behavior of amixer must not be changed for compatibility reason.

Takashi

#8 lore raw

Bug#663090: [alsa-devel] amixer: convert percentage into db wrongly

Quoted 134 lines · Takashi Iwai

At Fri, 9 Mar 2012 17:07:17 +0800,

Quoted 94 lines · Adam Lee
Quoted 58 lines · Takashi Iwai

At Fri, 9 Mar 2012 12:22:47 +0800,

Quoted 47 lines · Adam Lee

Add Vincent in cc, because conky read amixer's result.

Quoted 39 lines · Takashi Iwai
Quoted 12 lines · Adam Lee

Package: alsa-utils
Version: 1.0.25-1
Severity: important

db is not linear, but amixer believe it is.

"amixer get Master" says "Limits: Playback 0 - 74", then everytime I run "amixer -q sset Master 10%-", there is 8db dec.

Quoted 6 lines

For example, at first Master is 100% and 0db, both alsamixer and amixer think it is, and after I run "amixer -q sset Master 10%-", both alsamixer and amixer says Master is -8.00db, but alsamixer says it is 72%, amixer says it is 89%.

alsamixer is right, amixer calc and set wrongly.

No, both are correct. You are dreaming too much on the world unified percentage representation :)

The percentage in amixer has nothing to do with dB level. It's just the percentage of the raw value range of that mixer element. Thus showing 89% is correct. It's 10% down from 100% (1% is because of the resolution of the raw values).

Now, alsamixer shows the percentage in a different way. It's explained well in the source code (alsamixer/volume_mapping.c), but not mentioned in the man page, unfortunately.

* The mapping is designed so that the position in the interval is proportional
* to the volume as a human ear would perceive it (i.e., the position is the
* cubic root of the linear sample multiplication factor). For controls with
* a small range (24 dB or less), the mapping is linear in the dB values so
* that each step has the same size visually. Only for controls without dB
* information, a linear mapping of the hardware volume register values is used
* (this is the same algorithm as used in the old alsamixer).

Quoted 3 lines

The percentage representation in alsamixer corresponds to this mapping, thus it's neither dB nor linear percent.

Quoted 8 lines

Hi, Takashi

Thank you for replying. But I still insist this is a bug. Three questions:

1, several months ago, it's OK, both amixer and alsamixer use the human mapping(0-10% and 90%-100% are the same change by a human ear), why not now?

Quoted 8 lines

amixer hasn't been changed until yet. It handles either in raw values or in dB. No human-ear mapping at all. It's never changed since years, and won't be changed. If the volume mapping would be implemented to amixer in future, it must be only optional.

Only the recent alsamixer introduced the volume mapping to visualize the volumes reasonably.

OK, thank you. Maybe an optional will make everyone happy.

Quoted 7 lines
Quoted 3 lines

2, conky(Vincent, I mean ${mixer}), some other software, lot of user's scripts use amixer to set or get volume, expecting the human mapping, why change the behavior?

You must be smoking something bad. The behavior of amixer hasn't been changed.

I figured out a reason probably, when the limits range is wide, like 0-65536, amixer's mapping and alsamixer's human-ear mapping are close.

If I remember right, my hardware's limits was 0-65536, but it becomes 0-74 after I run "alsactl init", but unfortunately, I don't know how to modify it back.

Quoted 8 lines
Quoted 4 lines

3, alsamixer and amixer use the same dB value, why there is difference in percentage? If alsa-utils developer think the human mapping sucks, why you guys still use it in alsamixer? There is no "both correct", the difference confuses user...

That's true. alsamixer should have stopped showing the stupid percentage.

Quoted 8 lines
Quoted 4 lines

The biggest understand is that people (including you) think there is an absolutely perfect percentage definition for the sound level. It's an illusion.

I don't expect an absolutely perfect percentage definition. I want a human-ear mapping, which alsamixer does well, 100% is about as ten times loud as 10%.

How did you measure _quantitatively_ it's exactly ten times louder? And you think 50% is ten times loud as 5% volume, 10% is ten times loud as 1%? Things aren't so easy, unfortunately.

Quoted 2 lines

But amixer doesn't work like that, amixer's 100% is about as *one hundred times* as amixer's 10%.

Yes, this is what's amixer expected to behave. It's a value just representing the percentage of a "raw value" of the mixer element. It never says it's corresponding to any practical volume. This is the misunderstanding first of all.

For example, I guess in your 64k case, the raw value is even not in dB unit but it's a linear volume. amixer doesn't care. 10% means only the 6553 of 65536. That's all. So simple.
(In addition, amixer can handle dB, e.g. amixer set Master +10dB or
such. But it's not suitable for percentage unit because dB level can't be represented in the absolute percent volume -- what is 10% in dB?)

Quoted 3 lines

Maybe it is beautiful, and alsamixer's human-ear mapping is stupid in the sound science universe. But as a common user, I don't think so. And I don't know how you guys put up with it :(

No, you misunderstand what I wrote. alsamixer's mapping is really an improvement. That's why it was implemented recently. But if it shows a different number, user may wonder, just like you did. If you didn't see a number, you didn't notice the difference :)

Quoted 6 lines

But amixer wasn't changed. amixer is a tool to manipulate raw values. Of course, it'd be also nice to implement the same percentage expression, but as already mentioned, it should be activated only via an option. The default behavior of amixer must not be changed for compatibility reason.

OK.

Looking forward to the option, if your time and other capacity allow :)

#9 lore raw

At Fri, 9 Mar 2012 18:06:17 +0800,

Quoted 143 lines · Adam Lee
Quoted 134 lines · Takashi Iwai

At Fri, 9 Mar 2012 17:07:17 +0800,

Quoted 94 lines · Adam Lee
Quoted 58 lines · Takashi Iwai

At Fri, 9 Mar 2012 12:22:47 +0800,

Quoted 47 lines · Adam Lee

Add Vincent in cc, because conky read amixer's result.

Quoted 39 lines · Takashi Iwai
Quoted 12 lines · Adam Lee

Package: alsa-utils
Version: 1.0.25-1
Severity: important

db is not linear, but amixer believe it is.

"amixer get Master" says "Limits: Playback 0 - 74", then everytime I run "amixer -q sset Master 10%-", there is 8db dec.

Quoted 6 lines

For example, at first Master is 100% and 0db, both alsamixer and amixer think it is, and after I run "amixer -q sset Master 10%-", both alsamixer and amixer says Master is -8.00db, but alsamixer says it is 72%, amixer says it is 89%.

alsamixer is right, amixer calc and set wrongly.

No, both are correct. You are dreaming too much on the world unified percentage representation :)

The percentage in amixer has nothing to do with dB level. It's just the percentage of the raw value range of that mixer element. Thus showing 89% is correct. It's 10% down from 100% (1% is because of the resolution of the raw values).

Now, alsamixer shows the percentage in a different way. It's explained well in the source code (alsamixer/volume_mapping.c), but not mentioned in the man page, unfortunately.

* The mapping is designed so that the position in the interval is proportional
* to the volume as a human ear would perceive it (i.e., the position is the
* cubic root of the linear sample multiplication factor). For controls with
* a small range (24 dB or less), the mapping is linear in the dB values so
* that each step has the same size visually. Only for controls without dB
* information, a linear mapping of the hardware volume register values is used
* (this is the same algorithm as used in the old alsamixer).

Quoted 3 lines

The percentage representation in alsamixer corresponds to this mapping, thus it's neither dB nor linear percent.

Quoted 8 lines

Hi, Takashi

Thank you for replying. But I still insist this is a bug. Three questions:

1, several months ago, it's OK, both amixer and alsamixer use the human mapping(0-10% and 90%-100% are the same change by a human ear), why not now?

Quoted 8 lines

amixer hasn't been changed until yet. It handles either in raw values or in dB. No human-ear mapping at all. It's never changed since years, and won't be changed. If the volume mapping would be implemented to amixer in future, it must be only optional.

Only the recent alsamixer introduced the volume mapping to visualize the volumes reasonably.

OK, thank you. Maybe an optional will make everyone happy.

Quoted 7 lines
Quoted 3 lines

2, conky(Vincent, I mean ${mixer}), some other software, lot of user's scripts use amixer to set or get volume, expecting the human mapping, why change the behavior?

You must be smoking something bad. The behavior of amixer hasn't been changed.

I figured out a reason probably, when the limits range is wide, like 0-65536, amixer's mapping and alsamixer's human-ear mapping are close.

If I remember right, my hardware's limits was 0-65536, but it becomes 0-74 after I run "alsactl init", but unfortunately, I don't know how to modify it back.

Quoted 8 lines
Quoted 4 lines

3, alsamixer and amixer use the same dB value, why there is difference in percentage? If alsa-utils developer think the human mapping sucks, why you guys still use it in alsamixer? There is no "both correct", the difference confuses user...

That's true. alsamixer should have stopped showing the stupid percentage.

Quoted 8 lines
Quoted 4 lines

The biggest understand is that people (including you) think there is an absolutely perfect percentage definition for the sound level. It's an illusion.

I don't expect an absolutely perfect percentage definition. I want a human-ear mapping, which alsamixer does well, 100% is about as ten times loud as 10%.

How did you measure _quantitatively_ it's exactly ten times louder? And you think 50% is ten times loud as 5% volume, 10% is ten times loud as 1%? Things aren't so easy, unfortunately.

Quoted 2 lines

But amixer doesn't work like that, amixer's 100% is about as *one hundred times* as amixer's 10%.

Yes, this is what's amixer expected to behave. It's a value just representing the percentage of a "raw value" of the mixer element. It never says it's corresponding to any practical volume. This is the misunderstanding first of all.

For example, I guess in your 64k case, the raw value is even not in dB unit but it's a linear volume. amixer doesn't care. 10% means only the 6553 of 65536. That's all. So simple.
(In addition, amixer can handle dB, e.g. amixer set Master +10dB or
such. But it's not suitable for percentage unit because dB level can't be represented in the absolute percent volume -- what is 10% in dB?)

Quoted 3 lines

Maybe it is beautiful, and alsamixer's human-ear mapping is stupid in the sound science universe. But as a common user, I don't think so. And I don't know how you guys put up with it :(

No, you misunderstand what I wrote. alsamixer's mapping is really an improvement. That's why it was implemented recently. But if it shows a different number, user may wonder, just like you did. If you didn't see a number, you didn't notice the difference :)

Quoted 6 lines

But amixer wasn't changed. amixer is a tool to manipulate raw values. Of course, it'd be also nice to implement the same percentage expression, but as already mentioned, it should be activated only via an option. The default behavior of amixer must not be changed for compatibility reason.

Quoted 3 lines

OK.

Looking forward to the option, if your time and other capacity allow :)

The implementation isn't too hard. I wrote a quick patch now as below. It became bigger than I thought since it contains many clean-ups that are needed to adapt the mapped volume.

With the patch, amixer shows and reads the percent value with -M option just like in alsamixer.

Takashi

---

amixer/Makefile.am +1 -1
index fcd0e81..ba67a57 100644
@@ -4,7 +4,7 @@ LDADD = -lm
 # CFLAGS += -g -Wall
 
 bin_PROGRAMS = amixer
-amixer_SOURCES = amixer.c
+amixer_SOURCES = amixer.c ../alsamixer/volume_mapping.c
 noinst_HEADERS = amixer.h
 man_MANS = amixer.1
 EXTRA_DIST = amixer.1
amixer/amixer.c +140 -98

400 lines not on this page · raw message

#10 lore raw
Quoted 7 lines · Takashi Iwai

The implementation isn't too hard. I wrote a quick patch now as below. It became bigger than I thought since it contains many clean-ups that are needed to adapt the mapped volume.

With the patch, amixer shows and reads the percent value with -M option just like in alsamixer.

<snip>

Quoted 13 lines
amixer/amixer.c +2 -0
@@ -29,7 +29,9 @@
 #include <assert.h>
 #include <alsa/asoundlib.h>
 #include <sys/poll.h>
+#include <stdint.h>
 #include "amixer.h"
+#include "../alsamixer/volume_mapping.h"
 
 #define LEVEL_BASIC		(1<<0)
 #define LEVEL_INACTIVE		(1<<1)

amixer/amixer.c static int help(void) · line 76

Quoted 7 lines
amixer/amixer.c +2 -0
@@ -68,6 +70,8 @@ static int help(void)
 	printf("  -i,--inactive   show also inactive controls\n");
 	printf("  -a,--abstract L select abstraction level (none or basic)\n");
 	printf("  -s,--stdin      Read and execute commands from stdin
 sequentially\n");
+	printf("  -R,--raw-volume Use the raw value 
 (default)\n");
+	printf("  -M,--mapped-volume Use the mapped volume\n");

A small comment...
What if both -R and -M are used? Isn't -R equivalent to the absence of -M? Are both options necessary?

Regards

Alan

#11 lore raw

At Fri, 9 Mar 2012 12:19:03 +0000,

Quoted 22 lines · Alan Horstmann
Quoted 7 lines · Takashi Iwai

The implementation isn't too hard. I wrote a quick patch now as below. It became bigger than I thought since it contains many clean-ups that are needed to adapt the mapped volume.

With the patch, amixer shows and reads the percent value with -M option just like in alsamixer.

<snip>

Quoted 10 lines
amixer/amixer.c +2 -0
@@ -29,7 +29,9 @@
 #include <assert.h>
 #include <alsa/asoundlib.h>
 #include <sys/poll.h>
+#include <stdint.h>
 #include "amixer.h"
+#include "../alsamixer/volume_mapping.h"
 
Quoted 13 lines

amixer/amixer.c static int help(void) · line 76

Quoted 10 lines
amixer/amixer.c +2 -0
 #define LEVEL_BASIC		(1<<0)
 #define LEVEL_INACTIVE		(1<<1)
@@ -68,6 +70,8 @@ static int help(void)
 	printf("  -i,--inactive   show also inactive controls\n");
 	printf("  -a,--abstract L select abstraction level (none or basic)\n");
 	printf("  -s,--stdin      Read and execute commands from stdin
 sequentially\n");
+	printf("  -R,--raw-volume Use the raw value 
 (default)\n");
+	printf("  -M,--mapped-volume Use the mapped volume\n");

A small comment...
What if both -R and -M are used? Isn't -R equivalent to the absence of -M?

The option set later wins.

Takashi

#12 lore raw

Bug#663090: [Pkg-alsa-devel] Bug#663090: [alsa-devel] amixer: convert percentage into db wrongly

In reply to Takashi Iwai

Hey Takashi,

Quoted 6 lines · Takashi Iwai

The implementation isn't too hard. I wrote a quick patch now as below. It became bigger than I thought since it contains many clean-ups that are needed to adapt the mapped volume.

With the patch, amixer shows and reads the percent value with -M option just like in alsamixer.

I see this isn't in git.a-p.org yet. If you are considering adding it for 1.0.26, I'll cherry-pick it to make Adam's life easier. :)

Indeed, quite a big patch. Thanks for that!

Jordi

Signature · 3 lines
Jordi Mallach Pérez  --  Debian developer     http://www.debian.org/
[email protected]     [email protected]     http://www.sindominio.net/
GnuPG public key information available at http://oskuro.net/