mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-12 14:18:31 +00:00
pause action + started flag
This commit is contained in:
parent
75e57c75cf
commit
9c7d0951b7
@ -9,7 +9,8 @@ import { ClockWorker } from './clockworker.mjs';
|
||||
export class Scheduler {
|
||||
worker;
|
||||
pattern;
|
||||
phase;
|
||||
started = false;
|
||||
phase = 0;
|
||||
cps = 1;
|
||||
constructor({ interval = 0.1, onTrigger, onError, latency = 0.1 }) {
|
||||
this.worker = new ClockWorker((_, interval) => {
|
||||
@ -40,11 +41,17 @@ export class Scheduler {
|
||||
if (!this.pattern) {
|
||||
throw new Error('Scheduler: no pattern set! call .setPattern first.');
|
||||
}
|
||||
this.phase = 0;
|
||||
this.worker.start();
|
||||
this.started = true;
|
||||
}
|
||||
pause() {
|
||||
this.worker.stop();
|
||||
this.started = false;
|
||||
}
|
||||
stop() {
|
||||
this.phase = 0;
|
||||
this.worker.stop();
|
||||
this.started = false;
|
||||
}
|
||||
setPattern(pat) {
|
||||
this.pattern = pat;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user