From c6c5a3035c90f4a19e5cbd747bae5ccbff77806c Mon Sep 17 00:00:00 2001 From: "Jade (Rose) Rowland" Date: Mon, 13 May 2024 21:06:24 -0400 Subject: [PATCH] fixed non synced clock --- packages/core/controls.mjs | 4 ++-- packages/core/cyclist.mjs | 23 +++++------------------ 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/packages/core/controls.mjs b/packages/core/controls.mjs index b8cdb6ed7..06e808be4 100644 --- a/packages/core/controls.mjs +++ b/packages/core/controls.mjs @@ -434,12 +434,13 @@ export const { coarse } = registerControl('coarse'); * modulate the amplitude of a sound with a continuous waveform * * @name am + * @synonyms tremelo * @param {number | Pattern} speed modulation speed in cycles * @example * s("triangle").am("2").amshape("").amdepth(.5) * */ -export const { am } = registerControl(['am', 'amdepth', 'amskew', 'amphase']); +export const { am, tremolo } = registerControl(['am', 'amdepth', 'amskew', 'amphase'], 'tremolo'); /** * depth of amplitude modulation @@ -1582,7 +1583,6 @@ export const { zmod } = registerControl('zmod'); // like crush but scaled differently export const { zcrush } = registerControl('zcrush'); export const { zdelay } = registerControl('zdelay'); -export const { tremolo } = registerControl('tremolo'); export const { zzfx } = registerControl('zzfx'); /** diff --git a/packages/core/cyclist.mjs b/packages/core/cyclist.mjs index 75f92090c..5e2ee378a 100644 --- a/packages/core/cyclist.mjs +++ b/packages/core/cyclist.mjs @@ -34,15 +34,7 @@ export class Cyclist { try { const begin = this.lastEnd; - const end = this.num_cycles_at_cps_change + num_cycles_since_cps_change; - let cycle2 = this.now(); - //magic number that fixes cycle calcuation, cycle is probably not being calculated correctly - const modifier = this.cps * -interval; - cycle2 = cycle2 + modifier; - // let cycle = begin + (phase - t) * this.cps; - // cycle = begin t - // console.log({ phase, t, cycle2 }); if (phase < t) { // avoid querying haps that are in the past anyway console.log(`skip query: too late`); @@ -51,23 +43,18 @@ export class Cyclist { // query the pattern for events const haps = this.pattern.queryArc(begin, end, { _cps: this.cps }); - let mod2 = t - phase - this.latency; - mod2 = mod2 * this.cps; - console.log(this.clock.duration); + const cycle_gap = (t - phase - this.latency) * this.cps; + haps.forEach((hap) => { if (hap.hasOnset()) { const targetTime = (hap.whole.begin - this.num_cycles_at_cps_change) / this.cps + this.seconds_at_cps_change + latency; const duration = hap.duration / this.cps; + const cycle = hap.whole.begin.valueOf() + cycle_gap; // the following line is dumb and only here for backwards compatibility // see https://github.com/tidalcycles/strudel/pull/1004 - - const deadline = targetTime - phase; - // console.log(); - let cycle = hap.whole.begin.valueOf() + mod2; - - // console.log({ cycle, cycle2, mod2 }); - onTrigger?.(hap, deadline, duration, this.cps, targetTime, cycle); + const _deadline = targetTime - phase; + onTrigger?.(hap, _deadline, duration, this.cps, targetTime, cycle); } });