fixed non synced clock
This commit is contained in:
parent
e024ae2142
commit
c6c5a3035c
2 changed files with 7 additions and 20 deletions
|
|
@ -434,12 +434,13 @@ export const { coarse } = registerControl('coarse');
|
||||||
* modulate the amplitude of a sound with a continuous waveform
|
* modulate the amplitude of a sound with a continuous waveform
|
||||||
*
|
*
|
||||||
* @name am
|
* @name am
|
||||||
|
* @synonyms tremelo
|
||||||
* @param {number | Pattern} speed modulation speed in cycles
|
* @param {number | Pattern} speed modulation speed in cycles
|
||||||
* @example
|
* @example
|
||||||
* s("triangle").am("2").amshape("<tri saw ramp square>").amdepth(.5)
|
* s("triangle").am("2").amshape("<tri saw ramp square>").amdepth(.5)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export const { am } = registerControl(['am', 'amdepth', 'amskew', 'amphase']);
|
export const { am, tremolo } = registerControl(['am', 'amdepth', 'amskew', 'amphase'], 'tremolo');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* depth of amplitude modulation
|
* depth of amplitude modulation
|
||||||
|
|
@ -1582,7 +1583,6 @@ export const { zmod } = registerControl('zmod');
|
||||||
// like crush but scaled differently
|
// like crush but scaled differently
|
||||||
export const { zcrush } = registerControl('zcrush');
|
export const { zcrush } = registerControl('zcrush');
|
||||||
export const { zdelay } = registerControl('zdelay');
|
export const { zdelay } = registerControl('zdelay');
|
||||||
export const { tremolo } = registerControl('tremolo');
|
|
||||||
export const { zzfx } = registerControl('zzfx');
|
export const { zzfx } = registerControl('zzfx');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -34,15 +34,7 @@ export class Cyclist {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const begin = this.lastEnd;
|
const begin = this.lastEnd;
|
||||||
|
|
||||||
const end = this.num_cycles_at_cps_change + num_cycles_since_cps_change;
|
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) {
|
if (phase < t) {
|
||||||
// avoid querying haps that are in the past anyway
|
// avoid querying haps that are in the past anyway
|
||||||
console.log(`skip query: too late`);
|
console.log(`skip query: too late`);
|
||||||
|
|
@ -51,23 +43,18 @@ export class Cyclist {
|
||||||
|
|
||||||
// query the pattern for events
|
// query the pattern for events
|
||||||
const haps = this.pattern.queryArc(begin, end, { _cps: this.cps });
|
const haps = this.pattern.queryArc(begin, end, { _cps: this.cps });
|
||||||
let mod2 = t - phase - this.latency;
|
const cycle_gap = (t - phase - this.latency) * this.cps;
|
||||||
mod2 = mod2 * this.cps;
|
|
||||||
console.log(this.clock.duration);
|
|
||||||
haps.forEach((hap) => {
|
haps.forEach((hap) => {
|
||||||
if (hap.hasOnset()) {
|
if (hap.hasOnset()) {
|
||||||
const targetTime =
|
const targetTime =
|
||||||
(hap.whole.begin - this.num_cycles_at_cps_change) / this.cps + this.seconds_at_cps_change + latency;
|
(hap.whole.begin - this.num_cycles_at_cps_change) / this.cps + this.seconds_at_cps_change + latency;
|
||||||
const duration = hap.duration / this.cps;
|
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
|
// the following line is dumb and only here for backwards compatibility
|
||||||
// see https://github.com/tidalcycles/strudel/pull/1004
|
// see https://github.com/tidalcycles/strudel/pull/1004
|
||||||
|
const _deadline = targetTime - phase;
|
||||||
const deadline = targetTime - phase;
|
onTrigger?.(hap, _deadline, duration, this.cps, targetTime, cycle);
|
||||||
// console.log();
|
|
||||||
let cycle = hap.whole.begin.valueOf() + mod2;
|
|
||||||
|
|
||||||
// console.log({ cycle, cycle2, mod2 });
|
|
||||||
onTrigger?.(hap, deadline, duration, this.cps, targetTime, cycle);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue