mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-25 04:28:30 +00:00
fix: cyclist desync
This commit is contained in:
parent
bea25a28cb
commit
df23ea6cdf
@ -37,12 +37,17 @@ export class Cyclist {
|
|||||||
this.lastBegin = begin;
|
this.lastBegin = begin;
|
||||||
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;
|
||||||
this.lastEnd = end;
|
this.lastEnd = end;
|
||||||
|
this.lastTick = phase;
|
||||||
|
|
||||||
|
if (phase < t) {
|
||||||
|
// avoid querying haps that are in the past anyway
|
||||||
|
console.log(`skip query: too late`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 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 });
|
||||||
|
|
||||||
this.lastTick = phase;
|
|
||||||
|
|
||||||
haps.forEach((hap) => {
|
haps.forEach((hap) => {
|
||||||
if (hap.hasOnset()) {
|
if (hap.hasOnset()) {
|
||||||
const targetTime =
|
const targetTime =
|
||||||
|
|||||||
@ -26,8 +26,7 @@ function createClock(
|
|||||||
// callback as long as we're inside the lookahead
|
// callback as long as we're inside the lookahead
|
||||||
while (phase < lookahead) {
|
while (phase < lookahead) {
|
||||||
phase = round ? Math.round(phase * precision) / precision : phase;
|
phase = round ? Math.round(phase * precision) / precision : phase;
|
||||||
phase >= t && callback(phase, duration, tick, t);
|
callback(phase, duration, tick, t); // callback has to skip / handle phase < t!
|
||||||
phase < t && console.log('TOO LATE', phase); // what if latency is added from outside?
|
|
||||||
phase += duration; // increment phase by duration
|
phase += duration; // increment phase by duration
|
||||||
tick++;
|
tick++;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -274,7 +274,7 @@ export const superdough = async (value, t, hapDuration) => {
|
|||||||
// calculate absolute time
|
// calculate absolute time
|
||||||
t = typeof t === 'string' && t.startsWith('=') ? Number(t.slice(1)) : ac.currentTime + t;
|
t = typeof t === 'string' && t.startsWith('=') ? Number(t.slice(1)) : ac.currentTime + t;
|
||||||
if (t < ac.currentTime) {
|
if (t < ac.currentTime) {
|
||||||
console.log(
|
console.warn(
|
||||||
`[superdough]: cannot schedule sounds in the past (target: ${t.toFixed(2)}, now: ${ac.currentTime.toFixed(2)})`,
|
`[superdough]: cannot schedule sounds in the past (target: ${t.toFixed(2)}, now: ${ac.currentTime.toFixed(2)})`,
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user