mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-08 08:04:08 +02:00
Use quasi-logarithmic volume controls
This commit significantly improves the usability of the volume controls for controlling volume in a way that matches intuitively onto human needs and loudness perception. Using the third power of the volume is a good approximation of the quasi-logarithmic psychoacoustic system, while being defined everywhere and preserving the useful quality of 0% volume mapping onto gain 0.0. The use of this exact mapping function is a prior art established by e.g. PulseAudio, among many other programs. Fixes #24488
This commit is contained in:
parent
5c3f15af41
commit
6096116526
1 changed files with 9 additions and 6 deletions
|
@ -315,12 +315,15 @@ base::Observable<AudioMsgId> &Updated() {
|
||||||
|
|
||||||
// Thread: Any. Must be locked: AudioMutex.
|
// Thread: Any. Must be locked: AudioMutex.
|
||||||
float64 ComputeVolume(AudioMsgId::Type type) {
|
float64 ComputeVolume(AudioMsgId::Type type) {
|
||||||
|
const auto gain = [&] {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AudioMsgId::Type::Voice: return VolumeMultiplierAll;
|
case AudioMsgId::Type::Voice: return VolumeMultiplierAll;
|
||||||
case AudioMsgId::Type::Song: return VolumeMultiplierSong * mixer()->getSongVolume();
|
case AudioMsgId::Type::Song: return VolumeMultiplierSong * mixer()->getSongVolume();
|
||||||
case AudioMsgId::Type::Video: return mixer()->getVideoVolume();
|
case AudioMsgId::Type::Video: return mixer()->getVideoVolume();
|
||||||
}
|
}
|
||||||
return 1.;
|
return 1.;
|
||||||
|
}();
|
||||||
|
return gain * gain * gain;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mixer *mixer() {
|
Mixer *mixer() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue