From 910b5a7ae6c5cae64ed90e971bd9941b126e0293 Mon Sep 17 00:00:00 2001 From: meew0 Date: Sat, 2 Apr 2016 11:08:00 +0200 Subject: [PATCH] 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). --- src/Voice/VolumeTransformer.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Voice/VolumeTransformer.js b/src/Voice/VolumeTransformer.js index 7c9c18ecd..98c7d7b15 100644 --- a/src/Voice/VolumeTransformer.js +++ b/src/Voice/VolumeTransformer.js @@ -17,6 +17,12 @@ class Volume extends Transform { 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() { return this.volume; }