module/alsa: use channel’s dB range instead of raw volume, if available

For channels that have a defined dB range, use that instead of the raw
volume range when calculating the volume percent.

Also use the same logic as alsamixer when calculating the percent from
the dB values: assume a linear scale if the dB range is “small
enough”, and otherwise normalize it against a logarithmic scale.

With this, yambar’s “percent” value matches alsamixer’s exactly.

The ‘volume’ tag remains unchanged - it always reflects the raw volume
values.

Instead, we add a new tag ‘dB’, that reflects the dB values.

Closes #202
This commit is contained in:
Daniel Eklöf 2022-06-16 18:24:42 +02:00
parent a0c07d7836
commit 6c10eb2153
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
4 changed files with 141 additions and 20 deletions

View file

@ -25,10 +25,11 @@
* network: request link stats and expose under tags `dl-speed` and
`ul-speed` when `poll-interval` is set.
* new module: disk-io.
* alsa: `dB` tag ([#202][202])
[153]: https://codeberg.org/dnkl/yambar/issues/153
[159]: https://codeberg.org/dnkl/yambar/issues/159
[202]: https://codeberg.org/dnkl/yambar/issues/202
### Changed
@ -42,6 +43,8 @@
(e.g. `string: {text: "{tx-bitrate:mb}"}`).
* i3: newly created, and **unfocused** workspaces are now considered
non-empty ([#191][191])
* alsa: use dB instead of raw volume values, if possible, when
calculating the `percent` tag ([#202][202])
* **BREAKING CHANGE**: overhaul of the `map` particle. Instead of
specifying a `tag` and then an array of `values`, you must now
simply use an array of `conditions`, that consist of:
@ -83,6 +86,7 @@
[137]: https://codeberg.org/dnkl/yambar/issues/137
[175]: https://codeberg.org/dnkl/yambar/issues/172
[191]: https://codeberg.org/dnkl/yambar/issues/191
[202]: https://codeberg.org/dnkl/yambar/issues/202
### Deprecated