mirror of
https://codeberg.org/uzu/strudel
synced 2026-07-29 08:01:50 -04:00
formatting
This commit is contained in:
+24
-22
@@ -90,30 +90,32 @@ export class Cyclist {
|
||||
clearInterval,
|
||||
);
|
||||
|
||||
onPrepare? this.prepClock = createClock(
|
||||
getTime,
|
||||
(phase, duration, _, t) => {
|
||||
try {
|
||||
const start = Math.max(t, this.preparedUntil);
|
||||
end = t + this.prepareTime;
|
||||
this.preparedUntil = end;
|
||||
onPrepare
|
||||
? (this.prepClock = createClock(
|
||||
getTime,
|
||||
(phase, duration, _, t) => {
|
||||
try {
|
||||
const start = Math.max(t, this.preparedUntil);
|
||||
end = t + this.prepareTime;
|
||||
this.preparedUntil = end;
|
||||
|
||||
const haps = this.pattern.queryArc(start, end, { _cps: 1 });
|
||||
const haps = this.pattern.queryArc(start, end, { _cps: 1 });
|
||||
|
||||
haps.forEach((hap) => {
|
||||
onPrepare?.(hap);
|
||||
})
|
||||
} catch (e) {
|
||||
logger(`[cyclist] error: ${e.message}`);
|
||||
onError?.(e);
|
||||
}
|
||||
},
|
||||
1, // duration of each cycle
|
||||
1,
|
||||
0,
|
||||
setInterval,
|
||||
clearInterval,
|
||||
) : null;
|
||||
haps.forEach((hap) => {
|
||||
onPrepare?.(hap);
|
||||
});
|
||||
} catch (e) {
|
||||
logger(`[cyclist] error: ${e.message}`);
|
||||
onError?.(e);
|
||||
}
|
||||
},
|
||||
1, // duration of each cycle
|
||||
1,
|
||||
0,
|
||||
setInterval,
|
||||
clearInterval,
|
||||
))
|
||||
: null;
|
||||
}
|
||||
now() {
|
||||
if (!this.started) {
|
||||
|
||||
@@ -242,11 +242,11 @@ export const getTrigger =
|
||||
};
|
||||
|
||||
export const getPrepare =
|
||||
({defaultPrepare}) =>
|
||||
({ defaultPrepare }) =>
|
||||
async (hap) => {
|
||||
try {
|
||||
await defaultPrepare(hap);
|
||||
} catch (err) {
|
||||
logger(`[cyclist] error: ${err.message}`, 'error');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -23,10 +23,9 @@ export function setMaxPolyphony(polyphony) {
|
||||
}
|
||||
export const soundMap = map();
|
||||
|
||||
export function registerSound(key, onTrigger, data = {}, onPrepare = (() => {})) {
|
||||
export function registerSound(key, onTrigger, data = {}, onPrepare = () => {}) {
|
||||
key = key.toLowerCase().replace(/\s+/g, '_');
|
||||
soundMap.setKey(key, { onTrigger, data, onPrepare });
|
||||
|
||||
}
|
||||
|
||||
function aliasBankMap(aliasMap) {
|
||||
@@ -724,13 +723,11 @@ export const superdoughTrigger = (t, hap, ct, cps) => {
|
||||
};
|
||||
|
||||
export const prepare = (value) => {
|
||||
const {
|
||||
onPrepare,
|
||||
} = getSound(value.s);
|
||||
const { onPrepare } = getSound(value.s);
|
||||
if (onPrepare) {
|
||||
if (value.bank && value.s) {
|
||||
value.s = `${value.bank}_${value.s}`;
|
||||
}
|
||||
onPrepare(value);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -20,8 +20,7 @@ export const webaudioOutputTrigger = (t, hap, ct, cps) => superdough(hap2value(h
|
||||
export const webaudioOutput = (hap, deadline, hapDuration, cps, t) =>
|
||||
superdough(hap2value(hap), t ? `=${t}` : deadline, hapDuration);
|
||||
|
||||
export const webaudioPrepare = (hap) =>
|
||||
prepare(hap2value(hap));
|
||||
export const webaudioPrepare = (hap) => prepare(hap2value(hap));
|
||||
|
||||
Pattern.prototype.webaudio = function () {
|
||||
return this.onTrigger(webaudioOutputTrigger);
|
||||
|
||||
Reference in New Issue
Block a user