diff --git a/src/SoundPlayer.js b/src/SoundPlayer.js index 7a2f7d5..6c3154c 100644 --- a/src/SoundPlayer.js +++ b/src/SoundPlayer.js @@ -46,7 +46,7 @@ class SoundPlayer extends EventEmitter { * @type {boolean} */ get isStarting () { - return this.isPlaying && this.startingUntil > this.audioEngine.audioContext.currentTime; + return this.isPlaying && this.startingUntil > this.audioEngine.currentTime; } /** @@ -219,7 +219,8 @@ class SoundPlayer extends EventEmitter { this.isPlaying = true; - this.startingUntil = this.audioEngine.audioContext.currentTime + this.audioEngine.DECAY_DURATION; + const {currentTime, DECAY_DURATION} = this.audioEngine; + this.startingUntil = currentTime + DECAY_DURATION; this.emit('play'); } @@ -245,8 +246,8 @@ class SoundPlayer extends EventEmitter { taken.finished().then(() => taken.dispose()); taken.volumeEffect.set(0); - const {audioContext, DECAY_DURATION, DECAY_WAIT} = this.audioEngine; - taken.outputNode.stop(audioContext.currentTime + DECAY_WAIT + DECAY_DURATION); + const {currentTime, DECAY_WAIT, DECAY_DURATION} = this.audioEngine; + taken.outputNode.stop(currentTime + DECAY_WAIT + DECAY_DURATION); } /** diff --git a/src/effects/PanEffect.js b/src/effects/PanEffect.js index 2fa4360..01239da 100644 --- a/src/effects/PanEffect.js +++ b/src/effects/PanEffect.js @@ -62,16 +62,9 @@ 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, - this.audioEngine.audioContext.currentTime, - this.audioEngine.DECAY_DURATION - ); - this.rightGain.gain.setTargetAtTime( - rightVal, - this.audioEngine.audioContext.currentTime, - this.audioEngine.DECAY_DURATION - ); + const {currentTime, DECAY_WAIT, DECAY_DURATION} = this.audioEngine; + this.leftGain.gain.setTargetAtTime(leftVal, currentTime + DECAY_WAIT, DECAY_DURATION); + this.rightGain.gain.setTargetAtTime(rightVal, currentTime + DECAY_WAIT, DECAY_DURATION); } /** diff --git a/src/effects/VolumeEffect.js b/src/effects/VolumeEffect.js index bf38e5f..1d1506d 100644 --- a/src/effects/VolumeEffect.js +++ b/src/effects/VolumeEffect.js @@ -38,7 +38,7 @@ class VolumeEffect extends Effect { this.value = value; const {gain} = this.outputNode; - const {audioContext: {currentTime}, DECAY_DURATION, DECAY_WAIT} = this.audioEngine; + const {currentTime, DECAY_WAIT, DECAY_DURATION} = this.audioEngine; gain.setValueAtTime(gain.value, currentTime + DECAY_WAIT); gain.linearRampToValueAtTime(value / 100, currentTime + DECAY_WAIT + DECAY_DURATION); }