diff --git a/packages/core/clockworker.mjs b/packages/core/clockworker.mjs index 0515c0d0..ec09ef8e 100644 --- a/packages/core/clockworker.mjs +++ b/packages/core/clockworker.mjs @@ -12,10 +12,11 @@ const createWorker = (func) => new Worker(urlifyFunction(func)); // this is just a setInterval with a counter, running in a worker export class ClockWorker { worker; - interval = 1 / 20; // query span, use powers of 2 to get better float accuracy + interval = 1 / 20; // query span, use divisors of 1000 to get better accuracy tick = 0; - constructor(callback, interval = this.interval) { - this.interval = interval; + constructor(callback, interval) { + // for some reason the constructor default value won't do in prod build + this.interval = interval || this.interval; this.worker = createWorker(() => { // we cannot use closures here! let interval; @@ -47,7 +48,7 @@ export class ClockWorker { } }; }); - this.worker.postMessage({ interval }); + this.setInterval(this.interval); // const round = (n, d) => Math.round(n * d) / d; this.worker.onmessage = (e) => { if (e.data === 'tick') { diff --git a/packages/react/examples/nano-repl/src/App.jsx b/packages/react/examples/nano-repl/src/App.jsx index b8354ba6..4bd841d6 100644 --- a/packages/react/examples/nano-repl/src/App.jsx +++ b/packages/react/examples/nano-repl/src/App.jsx @@ -9,7 +9,7 @@ import './style.css'; // import { prebake } from '../../../../../repl/src/prebake.mjs'; // TODO: only import stuff when play is pressed? -await evalScope( +evalScope( controls, import('@strudel.cycles/core'), // import('@strudel.cycles/tone'),