Add a function to set the volume in a logarithmic way

so that 0.5 is -10 dB (half the perceived volume) and 2.0 is +10 dB (double the perceived volume).
This commit is contained in:
meew0
2016-04-02 11:08:00 +02:00
parent e8cc571d6a
commit 910b5a7ae6

View File

@@ -17,6 +17,12 @@ class Volume extends Transform {
this._volume = value;
}
// Set the volume so that a value of 0.5 is half the perceived volume and
// 2.0 is double the perceived volume.
setVolumeLogarithmic(value) {
this.volume = Math.pow(value, 1.660964);
}
get multiplier() {
return this.volume;
}