scheduler error handling

This commit is contained in:
Felix Roos 2022-11-10 22:25:58 +01:00
parent b5c51e231b
commit 1a1363ef77
3 changed files with 7 additions and 2 deletions

View File

@ -38,7 +38,7 @@ export class Cyclist {
}
});
} catch (e) {
console.warn('scheduler error', e);
console.warn('scheduler error: ', e.message);
onError?.(e);
}
}, // called slightly before each cycle

View File

@ -55,9 +55,13 @@ export const midi2note = (n) => {
export const mod = (n, m) => ((n % m) + m) % m;
export const getPlayableNoteValue = (hap) => {
let { value: note, context } = hap;
let { value, context } = hap;
let note = value;
if (typeof note === 'object' && !Array.isArray(note)) {
note = note.note || note.n || note.value;
if (note === undefined) {
throw new Error(`cannot find a playable note for ${JSON.stringify(value)}`);
}
}
// if value is number => interpret as midi number as long as its not marked as frequency
if (typeof note === 'number' && context.type !== 'frequency') {

View File

@ -30,6 +30,7 @@ function useStrudel({ defaultOutput, interval, getTime, evalOnMount = false, ini
setActiveCode(code);
setPattern(_pattern);
setEvalError();
setSchedulerError();
if (autolink) {
window.location.hash = '#' + encodeURIComponent(btoa(code));
}