Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PipeWire and volume level #1358

Closed
Audacious-Bot opened this issue Apr 26, 2024 · 7 comments
Closed

PipeWire and volume level #1358

Audacious-Bot opened this issue Apr 26, 2024 · 7 comments
Milestone

Comments

@Audacious-Bot
Copy link


Author Name: grayich grayich
Original Redmine Issue: https://redmine.audacious-media-player.org/issues/1218
Original Date: 2023-07-12


When outputting via (pulse, alsa, etc.), the volume changes in a linear relationship.

When audio is output via PipeWire, the volume changes in a logarithmic relationship.
It's inconvenient, you need to either make it linear like it's always been, or optional.

@Audacious-Bot
Copy link
Author


Original Redmine Comment
Author Name: Michael Schwendt
Original Date: 2023-07-20T09:49:49Z


There is nothing in the source code of Audacious' pipewire output plugin that confirms your assumption. Yet Pipewire itself may work differently than Pulseaudio or direct ALSA output due to handling per app volume in different ways. More trouble-shooting will be needed.

@Audacious-Bot
Copy link
Author


Original Redmine Comment
Author Name: John Lindgren
Original Date: 2023-07-21T05:14:06Z


I suspect this is a valid defect.

ALSA volume levels are typically percentages (0-100%) that translate linearly to decibel levels. It's been that way as long as I can remember, though it beats me if that's documented anywhere. On my system, each 5% up/down translates to a 3 dB change. (Nowadays, alsamixer uses some different, incomprehensible scheme, but that's just at the UI level; the underlying API calls haven't changed.)

On the other hand, the PipeWire documentation for SPA_PROP_channelVolumes says "0.0 is silence, 1.0 is without attenuation". It's exceptionally vague wording, but that suggests to me that the 0-1 range is meant to translate linearly to some reference voltage range. If that's the case, we should probably do some math in the get_volume/set_volume() methods so that the volume level in Audacious still translates to a decibel level.

I'm not interested in PipeWire personally, but if someone else wants to take a stab at a patch, the general rule is: a +20 dB increase means the voltage multiplies by 10x. You can also find a sample calculation in the audio_amplify() function (libaudcore/audio.cc).

@Audacious-Bot
Copy link
Author


Original Redmine Comment
Author Name: Artem S. Tashkinov
Original Date: 2023-08-09T07:48:33Z


This is what MPV/audio/out/ao_pulse.c ( https://github.com/mpv-player/mpv/blob/master/audio/out/ao_pulse.c ) uses for PulseAudio:

#define VOL_PA2MP(v) ((v) * 100.0 / PA_VOLUME_NORM)
#define VOL_MP2PA(v) lrint((v) * PA_VOLUME_NORM / 100)
</code>

Not sure if it's relevant, sorry if it's not.

Though for audio/out/ao_pipewire.c ( https://github.com/mpv-player/mpv/blob/master/audio/out/ao_pulse.c ) it's quite different.

@Audacious-Bot
Copy link
Author


Original Redmine Comment
Author Name: Thomas Lange
Original Date: 2023-11-04T11:58:52Z


I have asked the PipeWire developer(s), their answer is that PipeWire uses a linear scale for the volume.

https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3623

@john: Do you have further questions for them? I'm not sure how to proceed now.

@Audacious-Bot
Copy link
Author


Original Redmine Comment
Author Name: John Lindgren
Original Date: 2023-11-04T20:05:31Z


I think we have all the information we need. We just need to implement the decibel to linear translation now.

@Audacious-Bot
Copy link
Author


Original Redmine Comment
Author Name: Thomas Lange
Original Date: 2023-12-17T23:07:14Z


Please see/check my pull request:
audacious-media-player/audacious-plugins#146

@Audacious-Bot
Copy link
Author


Original Redmine Comment
Author Name: Thomas Lange
Original Date: 2023-12-18T17:33:46Z


Fixed with audacious-media-player/audacious-plugins@1f02fb1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant