fix: web midi

This commit is contained in:
Felix Roos 2022-11-10 18:12:38 +01:00
parent 372bdf8be7
commit eca92cf5b5
6 changed files with 249 additions and 230 deletions

View file

@ -12,7 +12,19 @@ export function repl({
transpiler,
onToggle,
}) {
const scheduler = new Cyclist({ interval, onTrigger: defaultOutput, onError: onSchedulerError, getTime, onToggle });
const scheduler = new Cyclist({
interval,
onTrigger: (hap, deadline, duration) => {
if (!hap.context.onTrigger) {
return defaultOutput(hap, deadline, duration);
}
// call signature of output / onTrigger is different...
return hap.context.onTrigger(getTime() + deadline, hap);
},
onError: onSchedulerError,
getTime,
onToggle,
});
const evaluate = async (code, autostart = true) => {
if (!code) {
throw new Error('no code to evaluate');