From b9519e51e163356d940f1638098820297625f691 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Tue, 2 Apr 2019 16:02:10 +0200 Subject: [PATCH] map volume to a logarithmic gain scale because that's how acoustics works, to get it right (unlike Scratch3) --- src/objects.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/objects.js b/src/objects.js index 1a0bbded..a84b2520 100644 --- a/src/objects.js +++ b/src/objects.js @@ -3274,7 +3274,7 @@ SpriteMorph.prototype.reportSounds = function () { SpriteMorph.prototype.setVolume = function (num) { this.volume = Math.max(Math.min(+num, 100), 0); this.getGainNode().gain.setValueAtTime( - this.volume / 100, + 1 / Math.pow(10, Math.log2(100 / this.volume)), this.audioContext().currentTime ); };