Project

General

Profile

Bug #1218

pipewire and volume level

Added by grayich grayich 2 months ago. Updated about 1 month ago.

Status:
New
Priority:
Minor
Assignee:
-
Category:
plugins/pipewire
Target version:
-
Start date:
July 12, 2023
Due date:
% Done:

0%

Estimated time:
Affects version:

Description

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.

History

#1 Updated by Michael Schwendt 2 months ago

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.

#2 Updated by John Lindgren 2 months ago

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).

#3 Updated by John Lindgren 2 months ago

  • Target version deleted (4.3.1)
  • Category set to plugins/pipewire

#4 Updated by Artem S. Tashkinov about 1 month ago

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)

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.

Also available in: Atom PDF