Skip to content

Commit

Permalink
getters for decibel and logarithmic volume (discordjs#1355)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
xDdude authored and amishshah committed Apr 11, 2017
1 parent 9e4bfff commit fdafdf6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/client/voice/util/VolumeInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit fdafdf6

Please sign in to comment.