diff --git a/packages/core/cyclist.mjs b/packages/core/cyclist.mjs index c835ca76..ae6b68fe 100644 --- a/packages/core/cyclist.mjs +++ b/packages/core/cyclist.mjs @@ -41,7 +41,7 @@ export class Cyclist { this.lastEnd = end; // query the pattern for events - const haps = this.pattern.queryArc(begin, end); + const haps = this.pattern.queryArc(begin, end, { _cps: this.cps }); const tickdeadline = phase - time; // time left until the phase is a whole number this.lastTick = time + tickdeadline; diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index 6a7b210b..408b5398 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -340,9 +340,9 @@ export class Pattern { * silence * @noAutocomplete */ - queryArc(begin, end) { + queryArc(begin, end, controls = {}) { try { - return this.query(new State(new TimeSpan(begin, end))); + return this.query(new State(new TimeSpan(begin, end), controls)); } catch (err) { logger(`[query]: ${err.message}`, 'error'); return []; @@ -2341,14 +2341,19 @@ export const splice = register( 'splice', function (npat, ipat, opat) { const sliced = slice(npat, ipat, opat); - return sliced.withHap(function (hap) { - return hap.withValue((v) => ({ - ...{ - speed: (1 / v._slices / hap.whole.duration) * (v.speed || 1), - unit: 'c', - }, - ...v, - })); + return new Pattern((state) => { + // TODO - default cps to 0.5 + const cps = state.controls._cps || 1; + const haps = sliced.query(state); + return haps.map((hap) => + hap.withValue((v) => ({ + ...{ + speed: (cps / v._slices / hap.whole.duration) * (v.speed || 1), + unit: 'c', + }, + ...v, + })), + ); }); }, false, // turns off auto-patternification