proper disconnect onend

This commit is contained in:
Felix Roos 2022-09-17 15:32:36 +02:00
parent cafcead62e
commit 1ccc391c8e

View File

@ -305,10 +305,8 @@ Pattern.prototype.out = function () {
chain.push(ac.destination);
// connect chain elements together
chain.slice(1).reduce((last, current) => last.connect(current), chain[0]);
// disconnect all nodes when hap is over to make sure they are garbage collected
/* setTimeout(() => {
chain.forEach((n) => n.disconnect());
}, (hapDuration + release + 0.1) * 1000); */
// disconnect all nodes when source node has ended:
chain[0].onended = () => chain.forEach((n) => n.disconnect());
} catch (e) {
console.warn('.out error:', e);
}