mirror of
https://github.com/Tonejs/Tone.js
synced 2025-01-13 12:28:47 +00:00
polysynth does not reschedule event if disposed
This commit is contained in:
parent
0346ca0c09
commit
e3a611ffaa
2 changed files with 17 additions and 1 deletions
|
@ -121,6 +121,20 @@ describe("PolySynth", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("can stop all sounds scheduled to start in the future when disposed", () => {
|
||||
return Offline(() => {
|
||||
const polySynth = new PolySynth();
|
||||
polySynth.set({ envelope: { release: 0.1 } });
|
||||
polySynth.toDestination();
|
||||
polySynth.triggerAttackRelease(["C4", "E4", "G4", "B4"], 0.2);
|
||||
return atTime(0.1, () => {
|
||||
polySynth.dispose();
|
||||
});
|
||||
}, 0.3).then((buffer) => {
|
||||
expect(buffer.isSilent()).to.be.true;
|
||||
});
|
||||
});
|
||||
|
||||
it("can be synced to the transport", () => {
|
||||
return Offline(({ transport }) => {
|
||||
const polySynth = new PolySynth(Synth, {
|
||||
|
|
|
@ -250,7 +250,9 @@ export class PolySynth<Voice extends Monophonic<any> = Synth> extends Instrument
|
|||
} else {
|
||||
// schedule it to start in the future
|
||||
this.context.setTimeout(() => {
|
||||
this._scheduleEvent(type, notes, time, velocity);
|
||||
if (!this.disposed) {
|
||||
this._scheduleEvent(type, notes, time, velocity);
|
||||
}
|
||||
}, time - this.now());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue