mirror of
https://github.com/Qz3rK/tdesktop.git
synced 2026-07-03 14:15: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:
committed by
John Preston
parent
5c3f15af41
commit
6096116526
@@ -315,12 +315,15 @@ base::Observable<AudioMsgId> &Updated() {
|
||||
|
||||
// Thread: Any. Must be locked: AudioMutex.
|
||||
float64 ComputeVolume(AudioMsgId::Type type) {
|
||||
switch (type) {
|
||||
case AudioMsgId::Type::Voice: return VolumeMultiplierAll;
|
||||
case AudioMsgId::Type::Song: return VolumeMultiplierSong * mixer()->getSongVolume();
|
||||
case AudioMsgId::Type::Video: return mixer()->getVideoVolume();
|
||||
}
|
||||
return 1.;
|
||||
const auto gain = [&] {
|
||||
switch (type) {
|
||||
case AudioMsgId::Type::Voice: return VolumeMultiplierAll;
|
||||
case AudioMsgId::Type::Song: return VolumeMultiplierSong * mixer()->getSongVolume();
|
||||
case AudioMsgId::Type::Video: return mixer()->getVideoVolume();
|
||||
}
|
||||
return 1.;
|
||||
}();
|
||||
return gain * gain * gain;
|
||||
}
|
||||
|
||||
Mixer *mixer() {
|
||||
|
||||
Reference in New Issue
Block a user