From 618239654f09130d4cc6cd890d69843bfac913ae Mon Sep 17 00:00:00 2001 From: "Michael \"Z\" Goddard" Date: Tue, 5 Jun 2018 14:42:46 -0400 Subject: [PATCH] fixup! extend existing effects from Effect --- src/AudioPlayer.js | 12 ++++++++---- src/effects/Effect.js | 16 +++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/AudioPlayer.js b/src/AudioPlayer.js index 0ba8f3d..9f3a3db 100644 --- a/src/AudioPlayer.js +++ b/src/AudioPlayer.js @@ -26,8 +26,8 @@ class AudioPlayer { // Chain the effects and player together with the audio engine. // outputNode -> "pitchEffect" -> panEffect -> audioEngine.input - panEffect.connect(this.audioEngine.inputNode); - pitchEffect.connect(panEffect.inputNode); + panEffect.connect(this.audioEngine); + pitchEffect.connect(panEffect); // reset effects to their default parameters this.clearEffects(); @@ -137,8 +137,12 @@ class AudioPlayer { this.outputNode.gain.setTargetAtTime(value / 100, 0, this.audioEngine.DECAY_TIME); } - connect (node) { - this.outputNode.connect(node); + /** + * Connnect this player's output to another audio node + * @param {object} target - target whose node to should be connected + */ + connect (target) { + this.outputNode.connect(target.getInputNode()); } /** diff --git a/src/effects/Effect.js b/src/effects/Effect.js index 3cc4b26..a607128 100644 --- a/src/effects/Effect.js +++ b/src/effects/Effect.js @@ -89,8 +89,8 @@ class Effect { // Connect or disconnect from the graph if this now applies or no longer // applies an effect. - if (this._isPatch !== _isPatch && this.targetNode !== null) { - this.connect(this.targetNode); + if (this._isPatch !== _isPatch && this.target !== null) { + this.connect(this.target); } } @@ -117,18 +117,16 @@ class Effect { return; } - const targetNode = target.getInputNode(); - - let nextNode = targetNode; + let nextTarget = target; if (this._isPatch) { - nextNode = this.inputNode; - this.outputNode.connect(targetNode); + nextTarget = this; + this.outputNode.connect(target.getInputNode()); } if (this.lastEffect === null) { - this.audioPlayer.connect(nextNode); + this.audioPlayer.connect(nextTarget); } else { - this.lastEffect.connect(nextNode); + this.lastEffect.connect(nextTarget); } }