mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-26 13:08:28 +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 {
|
export class Scheduler {
|
||||||
worker;
|
worker;
|
||||||
pattern;
|
pattern;
|
||||||
phase;
|
started = false;
|
||||||
|
phase = 0;
|
||||||
cps = 1;
|
cps = 1;
|
||||||
constructor({ interval = 0.1, onTrigger, onError, latency = 0.1 }) {
|
constructor({ interval = 0.1, onTrigger, onError, latency = 0.1 }) {
|
||||||
this.worker = new ClockWorker((_, interval) => {
|
this.worker = new ClockWorker((_, interval) => {
|
||||||
@ -40,11 +41,17 @@ export class Scheduler {
|
|||||||
if (!this.pattern) {
|
if (!this.pattern) {
|
||||||
throw new Error('Scheduler: no pattern set! call .setPattern first.');
|
throw new Error('Scheduler: no pattern set! call .setPattern first.');
|
||||||
}
|
}
|
||||||
this.phase = 0;
|
|
||||||
this.worker.start();
|
this.worker.start();
|
||||||
|
this.started = true;
|
||||||
|
}
|
||||||
|
pause() {
|
||||||
|
this.worker.stop();
|
||||||
|
this.started = false;
|
||||||
}
|
}
|
||||||
stop() {
|
stop() {
|
||||||
|
this.phase = 0;
|
||||||
this.worker.stop();
|
this.worker.stop();
|
||||||
|
this.started = false;
|
||||||
}
|
}
|
||||||
setPattern(pat) {
|
setPattern(pat) {
|
||||||
this.pattern = pat;
|
this.pattern = pat;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user