Skip to content
This repository was archived by the owner on May 16, 2023. It is now read-only.

event listener added on each event callback #101

@err0r500

Description

@err0r500

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions