[PR #443] [MERGED] [alsa] Implement cubic mapping for hardware mixers #928

Closed
opened 2026-02-27 20:00:29 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/librespot-org/librespot/pull/443
Author: @ashthespy
Created: 3/4/2020
Status: Merged
Merged: 7/29/2020
Merged by: @sashahilton00

Base: devHead: maped_mixer


📝 Commits (4)

  • 3dfad7f Implement mapped volume for alsa mixer
  • 527a4cc Better alsamixer volume mapping for hardware mixers
  • 4632881 Make alsamixer less verbose
  • 9e7180f Use mixer's mute switch if possible

📊 Changes

3 files changed (+171 additions, -23 deletions)

View changed files

📝 playback/src/mixer/alsamixer.rs (+163 -23)
📝 playback/src/mixer/mod.rs (+2 -0)
📝 src/main.rs (+6 -0)

📄 Description

This implements a cubic mapping for hardware mixers similar to alsamixer

Volume Mapping
In alsamixer, the volume is mapped to a value that is more natural for a human ear. 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).

Cherry picked from my old branch and did some housekeeping. It should work, but don't have access to a device with a hardware mixer currently to test.
Volunteers? @JPW21

Fixes #433

Note

This introduces a level of confusion as --linear-volume is how we map the request volume Spotify to our client. This value is then mapped cubically to the hardware mixer by default (similar to alsamixer and amixer -m), and can be overridden with the mixer-linear-volume flag.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/librespot-org/librespot/pull/443 **Author:** [@ashthespy](https://github.com/ashthespy) **Created:** 3/4/2020 **Status:** ✅ Merged **Merged:** 7/29/2020 **Merged by:** [@sashahilton00](https://github.com/sashahilton00) **Base:** `dev` ← **Head:** `maped_mixer` --- ### 📝 Commits (4) - [`3dfad7f`](https://github.com/librespot-org/librespot/commit/3dfad7f788c7f2999f2e6813a972758b3df16f97) Implement mapped volume for alsa mixer - [`527a4cc`](https://github.com/librespot-org/librespot/commit/527a4ccbe275ed93cb99b62e184dcb4799d600c6) Better `alsamixer` volume mapping for hardware mixers - [`4632881`](https://github.com/librespot-org/librespot/commit/46328810cb5028df18658b488ec50f895a07388d) Make `alsamixer` less verbose - [`9e7180f`](https://github.com/librespot-org/librespot/commit/9e7180feb4600248a507b40d1987bbe1a65507e2) Use mixer's mute switch if possible ### 📊 Changes **3 files changed** (+171 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `playback/src/mixer/alsamixer.rs` (+163 -23) 📝 `playback/src/mixer/mod.rs` (+2 -0) 📝 `src/main.rs` (+6 -0) </details> ### 📄 Description This implements a cubic mapping for hardware mixers similar to [`alsamixer`](https://linux.die.net/man/1/alsamixer) >Volume Mapping In alsamixer, the volume is mapped to a value that is more natural for a human ear. 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). Cherry picked from my old branch and did some housekeeping. It should work, but don't have access to a device with a hardware mixer currently to test. Volunteers? @JPW21 Fixes #433 #### Note This introduces a level of confusion as `--linear-volume` is how we map the request volume Spotify to our client. This value is then mapped cubically to the hardware mixer by default (similar to `alsamixer` and `amixer -m`), and can be overridden with the `mixer-linear-volume` flag. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:00:29 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#928
No description provided.