From d2b6cb40e33dd0b2e5eda7fcbee6bc52c79d20f8 Mon Sep 17 00:00:00 2001 From: Eric Rosenbaum Date: Tue, 9 Jan 2018 18:18:49 -0500 Subject: [PATCH] Disconnect audio nodes on dispose --- src/effects/PanEffect.js | 10 ++++++++++ src/index.js | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/effects/PanEffect.js b/src/effects/PanEffect.js index b8090e0..73a25b9 100644 --- a/src/effects/PanEffect.js +++ b/src/effects/PanEffect.js @@ -52,6 +52,16 @@ class PanEffect { connect (node) { this.channelMerger.connect(node); } + + /** + * Clean up and disconnect audio nodes. + */ + dispose () { + this.input.disconnect(); + this.leftGain.disconnect(); + this.rightGain.disconnect(); + this.channelMerger.disconnect(); + } } module.exports = PanEffect; diff --git a/src/index.js b/src/index.js index 501452f..286e723 100644 --- a/src/index.js +++ b/src/index.js @@ -133,6 +133,14 @@ class AudioPlayer { if (this.audioEngine === null) return; this.effectsNode.gain.setTargetAtTime(value / 100, 0, this.audioEngine.DECAY_TIME); } + + /** + * Clean up and disconnect audio nodes. + */ + dispose () { + this.panEffect.dispose(); + this.effectsNode.disconnect(); + } }