begin webaudio package

This commit is contained in:
Felix Roos 2022-04-01 15:44:17 +02:00
parent fb52227a92
commit 47a046ca1d
3 changed files with 167 additions and 0 deletions

View file

@ -0,0 +1,28 @@
class Scheduler {
metro;
constructor(interval = 0.2, lookahead = 0.2) {
this.metro = new Metro(
audioContext,
(begin, end, lookahead) => {
pattern.query(new State(new TimeSpan(begin - lookahead, end - lookahead))).forEach((e) => {
if (!e.part.begin.equals(e.whole.begin)) {
return;
}
if (e.context.createAudioNode) {
e.context.createAudioNode(e);
} else {
console.warn('unplayable event: no audio node');
}
});
},
interval,
lookahead,
);
}
start() {
this.metro.start();
}
stop() {
this.metro.stop();
}
}