add sync flag for neocyclist

This commit is contained in:
Felix Roos 2024-03-07 12:14:17 +01:00
parent 619ffdd5e1
commit 2fcbffeaf9
2 changed files with 7 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import { NeoCyclist } from './neocyclist.mjs';
import { Cyclist } from './cyclist.mjs';
import { evaluate as _evaluate } from './evaluate.mjs';
import { logger } from './logger.mjs';
import { setTime } from './time.mjs';
@ -15,6 +16,7 @@ export function repl({
onToggle,
editPattern,
onUpdateState,
sync = false,
}) {
const state = {
schedulerError: undefined,
@ -35,14 +37,16 @@ export function repl({
onUpdateState?.(state);
};
const scheduler = new NeoCyclist({
const schedulerOptions = {
onTrigger: getTrigger({ defaultOutput, getTime }),
getTime,
onToggle: (started) => {
updateState({ started });
onToggle?.(started);
},
});
};
const scheduler = sync ? new NeoCyclist(schedulerOptions) : new Cyclist(schedulerOptions);
let pPatterns = {};
let allTransform;

View File

@ -56,6 +56,7 @@ export function Repl({ embedded = false }) {
});
};
const editor = new StrudelMirror({
sync: true,
defaultOutput: webaudioOutput,
getTime: () => getAudioContext().currentTime,
transpiler,