Disconnect audio nodes on dispose

This commit is contained in:
Eric Rosenbaum 2018-01-09 18:18:49 -05:00
parent 97e099e6de
commit d2b6cb40e3
2 changed files with 18 additions and 0 deletions

View file

@ -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;

View file

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