formatting

This commit is contained in:
prezmop
2025-04-26 18:08:07 +09:00
parent e4099946cd
commit 88823d26b1
4 changed files with 30 additions and 32 deletions
+24 -22
View File
@@ -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) {
+2 -2
View File
@@ -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');
}
}
};
+3 -6
View File
@@ -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);
}
}
};
+1 -2
View File
@@ -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);