Skip to content

Commit

Permalink
use worker-timers for strudel clock
Browse files Browse the repository at this point in the history
- maybe solves callback clogging
  • Loading branch information
felixroos committed Feb 4, 2025
1 parent b96af3a commit 868f4d8
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"@strudel/webaudio": "^1.1.0",
"codemirror": "^6.0.1",
"hydra-synth": "^1.3.29",
"worker-timers": "^8.0.13",
"y-codemirror.next": "github:felixroos/y-codemirror.next#a75a1cbfddf6968d4ced07f6e47c314e4fd7c72f",
"y-indexeddb": "^9.0.9",
"y-protocols": "^1.0.5",
Expand Down
45 changes: 45 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/strudel.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { controls, evalScope, stack, evaluate, silence, getTrigger, setTime, register } from '@strudel/core';
import { controls, evalScope, stack, evaluate, silence, getTrigger, setTime, register, Cyclist } from '@strudel/core';
import { Framer } from '@strudel/draw';
import { registerSoundfonts } from '@strudel/soundfonts';
import { transpiler } from '@strudel/transpiler';
import { getAudioContext, initAudio, registerSynthSounds, samples, webaudioOutput } from '@strudel/webaudio';
import { setInterval, clearInterval } from 'worker-timers';

controls.createParam('docId');

Expand Down Expand Up @@ -67,6 +68,8 @@ export class StrudelSession {
this.scheduler = new Cyclist({
onTrigger: getTrigger({ defaultOutput: webaudioOutput, getTime }),
getTime,
setInterval,
clearInterval,
});
setTime(() => this.scheduler.now()); // this is cursed

Expand Down

0 comments on commit 868f4d8

Please sign in to comment.