fix: call setTime in initStrudel

+ return promise with scheduler
This commit is contained in:
Felix Roos 2024-04-03 23:02:42 +02:00
parent fde0da3b19
commit d06b70c28d

View File

@ -5,7 +5,7 @@ export * from '@strudel/transpiler';
export * from '@strudel/mini';
export * from '@strudel/tonal';
export * from '@strudel/webaudio';
import { Pattern, evalScope } from '@strudel/core';
import { Pattern, evalScope, setTime } from '@strudel/core';
import { initAudioOnFirstClick, registerSynthSounds, webaudioScheduler } from '@strudel/webaudio';
// import { registerSoundfonts } from '@strudel/soundfonts';
import { evaluate as _evaluate } from '@strudel/transpiler';
@ -33,11 +33,14 @@ export function initStrudel(options = {}) {
miniAllStrings();
const { prebake, ...schedulerOptions } = options;
scheduler = webaudioScheduler(schedulerOptions);
initDone = (async () => {
await defaultPrebake();
await prebake?.();
return scheduler;
})();
scheduler = webaudioScheduler(schedulerOptions);
setTime(() => scheduler.now());
return initDone;
}
window.initStrudel = initStrudel;