From a49d4e6d4356df0a1580b672dd578c13e200f4ec Mon Sep 17 00:00:00 2001 From: xDdude Date: Wed, 12 Apr 2017 01:21:00 +0800 Subject: [PATCH] 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 --- src/client/voice/util/VolumeInterface.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/client/voice/util/VolumeInterface.js b/src/client/voice/util/VolumeInterface.js index 730b141a8..8342393a4 100644 --- a/src/client/voice/util/VolumeInterface.js +++ b/src/client/voice/util/VolumeInterface.js @@ -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;