mirror of
https://github.com/danbulant/discord.js
synced 2026-06-07 00:32:03 +00:00
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:
parent
e8cc571d6a
commit
910b5a7ae6
1 changed files with 6 additions and 0 deletions
|
|
@ -17,6 +17,12 @@ class Volume extends Transform {
|
||||||
this._volume = value;
|
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() {
|
get multiplier() {
|
||||||
return this.volume;
|
return this.volume;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue