getters for decibel and logarithmic volume (#1355)

* getters for decibel and logarithmic volume

I don't really understand where the conversion numbers come from but having this allows for an easy way to get the volume back based on what method you used to set it. I think the math is right, but yeah I've just used the conversion numbers from the other methods.

* fix trailing spaces
This commit is contained in:
xDdude
2017-04-12 01:21:00 +08:00
committed by Amish Shah
parent 84aab1021a
commit a49d4e6d43

View File

@@ -63,6 +63,24 @@ class VolumeInterface extends EventEmitter {
get volume() {
return this._volume;
}
/**
* The current volume of the broadcast in decibels
* @readonly
* @type {number}
*/
get volumeDecibels() {
return Math.log10(this._volume) * 20;
}
/**
* The current volume of the broadcast from a logarithmic scale
* @readonly
* @type {number}
*/
get volumeLogarithmic() {
return Math.pow(this._volume, 1 / 1.660964);
}
}
module.exports = VolumeInterface;