mirror of
https://github.com/danbulant/discord.js
synced 2026-05-24 20:42:27 +00:00
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:
parent
84aab1021a
commit
a49d4e6d43
1 changed files with 18 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue