[GH-ISSUE #39] ALSA: support selection of ALSA mixer - for (hardware-based) volume control #28

Closed
opened 2026-02-27 19:28:24 +03:00 by kerem · 4 comments
Owner

Originally created by @sashahilton00 on GitHub (Jan 29, 2018).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/39

Issue by arigit
Thursday Jan 05, 2017 at 04:29 GMT
Originally opened as https://github.com/plietar/librespot/issues/140


Some DAC cards support hardware-based volume control. Example: HiFiBerry DAC+ pro on Raspberry.
Using librespot (v20161230-7fd8503) from: https://github.com/herrernst/librespot/releases

On raspberry pi + OSMC (raspbian) + above mentioned DAC. Works very well out of the box.

Running the client with:

/home/osmc/librespot/librespot --name Raspberry --cache /tmp --bitrate 320 --backend alsa --device hw:0

I notice using alsamixer and librespot in verbose mode that changing that volume changes in the client causes some events in librespot,

DEBUG:librespot::spirc: kMessageTypeVolume ...
...

the audio volume does change, increase/decrease, however alsamixer doesn't show any actual mixer volume change at all in any of its mixers, which seems to indicate that the volume change is done by librespot itself as a "software volume change". Higher end DACs can control volume via hardware which is preferable. In the case of the HiFiBerry DAC pro, the Alsa mixer is called "Digital" (shows up as one of the mixers displayed by the "alsamixer" tool)

When using spotify-connect-web, running it as:

spotify-connect-web --key /home/your-user/your-key.key --name Raspberry --bitrate 320 --playback_device hw:0 --mixer Digital

...any volume change in the spotify client causes the alsamixer "Digital" mixer to reflect the change (value between 100 and 0), which indicates that the volume change is being done via hardware. Note that spotify-connect-web also supports "software-based volume control" if desired

Originally created by @sashahilton00 on GitHub (Jan 29, 2018). Original GitHub issue: https://github.com/librespot-org/librespot/issues/39 <a href="https://github.com/arigit"><img src="https://avatars0.githubusercontent.com/u/652673?v=4" align="left" width="96" height="96" hspace="10"></img></a> **Issue by [arigit](https://github.com/arigit)** _Thursday Jan 05, 2017 at 04:29 GMT_ _Originally opened as https://github.com/plietar/librespot/issues/140_ ---- Some DAC cards support hardware-based volume control. Example: HiFiBerry DAC+ pro on Raspberry. Using librespot (v20161230-7fd8503) from: https://github.com/herrernst/librespot/releases On raspberry pi + OSMC (raspbian) + above mentioned DAC. Works very well out of the box. Running the client with: /home/osmc/librespot/librespot --name Raspberry --cache /tmp --bitrate 320 --backend alsa --device hw:0 I notice using alsamixer and librespot in verbose mode that changing that volume changes in the client causes some events in librespot, DEBUG:librespot::spirc: kMessageTypeVolume ... ... the audio volume does change, increase/decrease, however alsamixer doesn't show any actual mixer volume change at all in any of its mixers, which seems to indicate that the volume change is done by librespot itself as a "software volume change". Higher end DACs can control volume via hardware which is preferable. In the case of the HiFiBerry DAC pro, the Alsa mixer is called "Digital" (shows up as one of the mixers displayed by the "alsamixer" tool) When using spotify-connect-web, running it as: spotify-connect-web --key /home/your-user/your-key.key --name Raspberry --bitrate 320 --playback_device hw:0 --mixer Digital ...any volume change in the spotify client causes the alsamixer "Digital" mixer to reflect the change (value between 100 and 0), which indicates that the volume change is being done via hardware. Note that spotify-connect-web also supports "software-based volume control" if desired
kerem 2026-02-27 19:28:24 +03:00
Author
Owner

@sashahilton00 commented on GitHub (Jan 29, 2018):

Comment by plietar
Thursday Jan 05, 2017 at 13:31 GMT


This is definitely a frequent request (#128 and #75).
Originally, librespot only supported PortAudio, which doesn't have any sort of volume control.

@joerg-krause had an implementation for ALSA at some point. It would need to be adjusted to at least fallback to software volume control for other backends

<!-- gh-comment-id:361259565 --> @sashahilton00 commented on GitHub (Jan 29, 2018): <a href="https://github.com/plietar"><img src="https://avatars0.githubusercontent.com/u/1489775?v=4" align="left" width="48" height="48" hspace="10"></img></a> **Comment by [plietar](https://github.com/plietar)** _Thursday Jan 05, 2017 at 13:31 GMT_ ---- This is definitely a frequent request (#128 and #75). Originally, librespot only supported PortAudio, which doesn't have any sort of volume control. @joerg-krause had an implementation for ALSA at some point. It would need to be adjusted to at least fallback to software volume control for other backends
Author
Owner

@sashahilton00 commented on GitHub (Jan 29, 2018):

Comment by arigit
Sunday Mar 26, 2017 at 18:04 GMT


Noticed that today's binary release for raspberry by @herrernst supports a "--mixer" option!
Tried it & librespot crashed like so:

/home/osmc/librespot# /home/osmc/librespot/librespot --name Raspberry --cache /tmp --bitrate 320 --backend alsa --device hw:0 --mixer Digital
INFO:librespot: librespot 6f1b785 (2017-03-26). Built on 2017-03-26.
thread 'main' panicked at 'Invalid mixer', /buildslave/rust-buildbot/slave/stable-dist-rustc-cross-host-linux/build/src/libcore/option.rs:715
note: Run with RUST_BACKTRACE=1 for a backtrace.

Amixer shows that the "Digital" mixer exists:

...
Simple mixer control 'Digital',0
Capabilities: pvolume pswitch
Playback channels: Front Left - Front Right
Limits: Playback 0 - 207
Mono:
Front Left: Playback 207 [100%] [0.00dB] [on]
Front Right: Playback 207 [100%] [0.00dB] [on]
...

Tried with other mixers shown by alsamixer & amixer, and they all crash librespot

Wondering if the --mixer command line switch is not yet ready for use, or if it's meant to be used differently

<!-- gh-comment-id:361259597 --> @sashahilton00 commented on GitHub (Jan 29, 2018): <a href="https://github.com/arigit"><img src="https://avatars0.githubusercontent.com/u/652673?v=4" align="left" width="48" height="48" hspace="10"></img></a> **Comment by [arigit](https://github.com/arigit)** _Sunday Mar 26, 2017 at 18:04 GMT_ ---- Noticed that today's binary release for raspberry by @herrernst supports a "--mixer" option! Tried it & librespot crashed like so: > /home/osmc/librespot# /home/osmc/librespot/librespot --name Raspberry --cache /tmp --bitrate 320 --backend alsa --device hw:0 --mixer Digital > INFO:librespot: librespot 6f1b785 (2017-03-26). Built on 2017-03-26. > thread 'main' panicked at 'Invalid mixer', /buildslave/rust-buildbot/slave/stable-dist-rustc-cross-host-linux/build/src/libcore/option.rs:715 > note: Run with `RUST_BACKTRACE=1` for a backtrace. Amixer shows that the "Digital" mixer exists: ... Simple mixer control 'Digital',0 Capabilities: pvolume pswitch Playback channels: Front Left - Front Right Limits: Playback 0 - 207 Mono: Front Left: Playback 207 [100%] [0.00dB] [on] Front Right: Playback 207 [100%] [0.00dB] [on] ... Tried with other mixers shown by alsamixer & amixer, and they all crash librespot Wondering if the --mixer command line switch is not yet ready for use, or if it's meant to be used differently
Author
Owner

@sashahilton00 commented on GitHub (Jan 29, 2018):

Comment by joerg-krause
Monday Mar 27, 2017 at 05:39 GMT


It's meant to use different. For now, there is only one mixer supported: softmixer. --mixer is not the ALSA mixer device name.

<!-- gh-comment-id:361259618 --> @sashahilton00 commented on GitHub (Jan 29, 2018): <a href="https://github.com/joerg-krause"><img src="https://avatars2.githubusercontent.com/u/6870896?v=4" align="left" width="48" height="48" hspace="10"></img></a> **Comment by [joerg-krause](https://github.com/joerg-krause)** _Monday Mar 27, 2017 at 05:39 GMT_ ---- It's meant to use different. For now, there is only one mixer supported: softmixer. `--mixer` is not the ALSA mixer device name.
Author
Owner

@ComlOnline commented on GitHub (Jan 29, 2018):

This is @joerg-krause's implementation that @plietar referenced. @joerg-krause Did you make any more progress with this?

And as an addition note I'm going to close this issue and refer people to #45 for continued discussion as it looks more informative.

<!-- gh-comment-id:361426372 --> @ComlOnline commented on GitHub (Jan 29, 2018): [This](https://github.com/joerg-krause/librespot/commit/9af911803eb2ceaf617c9ebb47e98d62f81e2d55) is @joerg-krause's implementation that @plietar referenced. @joerg-krause Did you make any more progress with this? And as an addition note I'm going to close this issue and refer people to #45 for continued discussion as it looks more informative.
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#28
No description provided.