start audio param transition at now

Explicitly start the param transitions at the audio context's now time.
This commit is contained in:
Michael "Z" Goddard 2018-06-11 15:20:48 -04:00
parent f6d5353e83
commit 0059ff53e1
No known key found for this signature in database
GPG key ID: 762CD40DD5349872
2 changed files with 15 additions and 3 deletions

View file

@ -58,8 +58,16 @@ class PanEffect extends Effect {
const leftVal = Math.cos(p * Math.PI / 2);
const rightVal = Math.sin(p * Math.PI / 2);
this.leftGain.gain.setTargetAtTime(leftVal, 0, this.audioEngine.DECAY_TIME);
this.rightGain.gain.setTargetAtTime(rightVal, 0, this.audioEngine.DECAY_TIME);
this.leftGain.gain.setTargetAtTime(
leftVal,
this.audioEngine.audioContext.currentTime,
this.audioEngine.DECAY_TIME
);
this.rightGain.gain.setTargetAtTime(
rightVal,
this.audioEngine.audioContext.currentTime,
this.audioEngine.DECAY_TIME
);
}
/**

View file

@ -34,7 +34,11 @@ class VolumeEffect extends Effect {
this.value = value;
// A gain of 1 is normal. Scale down scratch's volume value. Apply the
// change over a tiny period of time.
this.outputNode.gain.setTargetAtTime(value / 100, 0, this.audioEngine.DECAY_TIME);
this.outputNode.gain.setTargetAtTime(
value / 100,
this.audioEngine.audioContext.currentTime,
this.audioEngine.DECAY_TIME
);
}
/**