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(); + } }