Skip to content

Commit

Permalink
fix(strudel): Workaround - On init, eval silence to make sure everyth…
Browse files Browse the repository at this point in the history
…ing is loaded
  • Loading branch information
munshkr committed Mar 31, 2024
1 parent 6ee1313 commit c0f05cb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/web/src/lib/strudel-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export class StrudelWrapper {
this._session = session;

let lastFrame: number | null = null;

this.framer = new Framer(
() => {
const phase = this._repl.scheduler.now();
Expand All @@ -71,6 +70,9 @@ export class StrudelWrapper {
if (!this._editorRefs) {
return;
}
if (!this._repl.scheduler.pattern) {
return;
}
// queries the stack of strudel patterns for the current time
const allHaps = this._repl.scheduler.pattern.queryArc(
Math.max(lastFrame!, phase - 1 / 10), // make sure query is not larger than 1/10 s
Expand Down Expand Up @@ -144,8 +146,14 @@ export class StrudelWrapper {
getTime: () => getAudioContext().currentTime,
transpiler,
});

this.framer.start(); // TODO: when to start stop?

// For some reason, we need to make a no-op evaluation ("silence") to make
// sure everything is loaded correctly.
const pattern = await this._repl.evaluate(`silence`);
await this._repl.scheduler.setPattern(pattern, true);

this.initialized = true;
}

Expand Down

0 comments on commit c0f05cb

Please sign in to comment.