improve api for web package

This commit is contained in:
Felix Roos 2023-05-07 22:36:26 +02:00
parent 3b631cb6af
commit 12228c56d9
10 changed files with 160 additions and 73 deletions

View file

@ -243,3 +243,16 @@ Pattern.prototype.webaudio = function () {
// TODO: refactor (t, hap, ct, cps) to (hap, deadline, duration) ?
return this.onTrigger(webaudioOutputTrigger);
};
export function webaudioScheduler(options = {}) {
options = {
getTime: () => getAudioContext().currentTime,
defaultOutput: webaudioOutput,
...options,
};
const { defaultOutput, getTime } = options;
return new strudel.Cyclist({
...options,
onTrigger: strudel.getTrigger({ defaultOutput, getTime }),
});
}