ability to mute a sequence

fixes #823
This commit is contained in:
Yotam Mann 2021-01-18 23:27:55 -05:00
parent de1dddc5b9
commit ac856bc82b
2 changed files with 12 additions and 1 deletions

View file

@ -299,6 +299,17 @@ describe("Sequence", () => {
});
});
it("can mute the callback", () => {
return Offline(({ transport }) => {
const seq = new Sequence(() => {
throw new Error("shouldn't call this callback");
}, [0, 0.1, 0.2, 0.3]).start();
seq.mute = true;
expect(seq.mute).to.be.true;
transport.start();
}, 0.5);
});
});
context("Looping", () => {

View file

@ -102,7 +102,7 @@ export class Sequence<ValueType = any> extends ToneEvent<ValueType> {
* The internal callback for when an event is invoked
*/
private _seqCallback(time: Seconds, value: any): void {
if (value !== null) {
if (value !== null && !this.mute) {
this.callback(time, value);
}
}