map volume to a logarithmic gain scale

because that's how acoustics works, to get it right (unlike Scratch3)
pull/89/head
jmoenig 2019-04-02 16:02:10 +02:00
rodzic 53140c9108
commit b9519e51e1
1 zmienionych plików z 1 dodań i 1 usunięć

Wyświetl plik

@ -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
);
};