do not reset cps before eval #517

This commit is contained in:
Felix Roos 2023-03-23 22:34:25 +01:00
parent d17543d5d9
commit 8617b9164e
2 changed files with 1 additions and 11 deletions

View File

@ -42,17 +42,6 @@ export function repl({
}
try {
beforeEval?.({ code });
scheduler.setCps(1); // reset cps in case the code does not contain a setCps call
// problem: when the code does contain a setCps after an awaited promise,
// the cps will be 1 until the promise resolves
// example:
/*
await new Promise(resolve => setTimeout(resolve,1000))
setCps(.5)
note("c a f e")
*/
// to make sure the setCps inside the code is called immediately,
// it has to be placed first
let { pattern } = await _evaluate(code, transpiler);
logger(`[eval] code updated`);

View File

@ -200,6 +200,7 @@ export function Repl({ embedded = false }) {
logger(`[repl] ✨ loading random tune "${name}"`);
clearCanvas();
resetLoadedSounds();
scheduler.setCps(1);
await prebake(); // declare default samples
await evaluate(code, false);
};