From 88823d26b15c7ac90d2b55a03ee4f6d29c5ffb5d Mon Sep 17 00:00:00 2001 From: prezmop Date: Sat, 26 Apr 2025 18:08:07 +0900 Subject: [PATCH] formatting --- packages/core/cyclist.mjs | 46 ++++++++++++++++-------------- packages/core/repl.mjs | 4 +-- packages/superdough/superdough.mjs | 9 ++---- packages/webaudio/webaudio.mjs | 3 +- 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/packages/core/cyclist.mjs b/packages/core/cyclist.mjs index 5324b5e93..1447a3915 100644 --- a/packages/core/cyclist.mjs +++ b/packages/core/cyclist.mjs @@ -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) { diff --git a/packages/core/repl.mjs b/packages/core/repl.mjs index 72be00b31..b50451d0b 100644 --- a/packages/core/repl.mjs +++ b/packages/core/repl.mjs @@ -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'); } - } + }; diff --git a/packages/superdough/superdough.mjs b/packages/superdough/superdough.mjs index bbc2f9fe1..2a1377803 100644 --- a/packages/superdough/superdough.mjs +++ b/packages/superdough/superdough.mjs @@ -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); } -} +}; diff --git a/packages/webaudio/webaudio.mjs b/packages/webaudio/webaudio.mjs index 21a2bc826..97dd89694 100644 --- a/packages/webaudio/webaudio.mjs +++ b/packages/webaudio/webaudio.mjs @@ -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);