[RFC] (ao_pipewire:) logarithmic volume control #15836
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a proof of concept to get logarithmic volume control with
ao_pipewire, because a logarithmic function best describes human
loudness perception. Anything in the analog world, e.g. HiFi amps, uses
logarithmic potentiometers in their volume control circuitry for this
reason.
There is an important difference though. The 0dB, aka 100% full blast,
mark is shifted by 100, so as to not mess up the volume control code,
thus 100, in this context, means 0dB and is actually the same as before
in that respect. The only noticeable differences are:
1) volume in-/decrements are now in decibels and
2) 0 is actually 2 in the mixer controls, e.g. pulsemixer
As for 1), a good minimum in-/decrement is +/-3 as that is considered
just significant enough to make a difference. As a side note, the cutoff
frequency of a low-pass filter, for instance, is defined as the
frequency at which the response has dropped by -3dB for this reason.
As for 2), a linear value of zero is impossible on a logarithmic scale
as that would equate to -infinity decibels. But, for all intents and
purposes, -100dB is virtually silent.
The reason for this being an RFC is that the proper way, as may have
become clear by, would be to represent 0dB as such in all the user
facing interfaces. But this author has no idea how one would go about
that. Maybe the above is sufficient, as in: it's not technically correct
but good enough for our purposes.
Also the scale to the other end, the positive values, is way too liberal
with possible values of +100dB, as that would be far above and beyond
any reasonable "overdrive" amplification. But this author has volume-max
set to 100 anyway, since over-amplification is basically just asking for
clipping. A somewhat reasonable maximum could be 112, aka +12dB, which
should be plenty over-amplified already, but if you must...
As a longer term goal this author would like to see all ao_* modules
using a logarithmic volume scale, as it is "the only correct way"(tm).
;-)