Hi,
I try to loop on a sample by adding a onended event to it (once). The problem is : when run in a browser, the JS event listeners count increment on each loop. It seems that something can't be garbage collected but I can't figure out what.
Here's a minimal example that reproduces the issue (I try to avoid references to global vars in the play function, without success):
const AudioContext = window.AudioContext || window.webkitAudioContext || false;
const ac = new AudioContext();
const play = (organ, now) => {
organ.play("C2").stop(now + 3);
};
Soundfont.instrument(ac, "drawbar_organ").then((organ) => {
organ.on("ended", () => play(organ, ac.currentTime));
play(organ, ac.currentTime);
});