This commit is contained in:
Alex McLean
2025-10-23 21:26:27 +01:00
parent 52931e879d
commit 77a7a148f0
3 changed files with 9 additions and 8 deletions
+1 -2
View File
@@ -58,7 +58,6 @@ export class Cyclist {
// query the pattern for events
const haps = this.pattern.queryArc(begin, end, { _cps: this.cps, cyclist: 'cyclist' });
haps.forEach((hap) => {
if (hap.hasOnset() || hap.context.processParts) {
const targetTime =
@@ -68,7 +67,7 @@ export class Cyclist {
// see https://codeberg.org/uzu/strudel/pulls/1004
const deadline = targetTime - phase;
// this onTrigger has another signature
onTrigger?.(hap, deadline, duration, this.cps, targetTime);
onTrigger?.(hap, deadline, duration, this.cps, targetTime, begin);
if (hap.value.cps !== undefined && this.cps != hap.value.cps) {
this.cps = hap.value.cps;
this.num_ticks_since_cps_change = 0;
+1 -1
View File
@@ -44,7 +44,7 @@ export class NeoCyclist {
const timeUntilTrigger = cycleToSeconds(hap.whole.begin - this.cycle, this.cps);
const targetTime = timeUntilTrigger + currentTime + this.latency;
const duration = cycleToSeconds(hap.duration, this.cps);
onTrigger?.(hap, 0, duration, this.cps, targetTime);
onTrigger?.(hap, 0, duration, this.cps, targetTime, begin);
}
});
};
+7 -5
View File
@@ -67,7 +67,7 @@ export async function oscTrigger(hap, currentTime, cps = 1, targetTime) {
ws.send(JSON.stringify(msg));
}
export async function superdirtTrigger(hap, currentTime, cps = 1, targetTime) {
export async function superdirtTrigger(hap, currentTime, cps = 1, targetTime, queryBegin) {
const ws = await connect();
const controls = parseControlsFromHap(hap, cps);
const ts = collator.calculateTimestamp(currentTime, targetTime) * 1000;
@@ -79,6 +79,8 @@ export async function superdirtTrigger(hap, currentTime, cps = 1, targetTime) {
for (const [k, v] of Object.entries(controls)) {
if (k.startsWith('^')) {
const offset = hap.part.begin.sub(queryBegin) / cps;
console.log('part begin', +hap.part.begin, 'qBegin', queryBegin, 'adding', offset, 'to', ts);
const bus_id = v;
const bus_value = controls[k.substring(1)];
const msg = JSON.stringify({
@@ -86,18 +88,18 @@ export async function superdirtTrigger(hap, currentTime, cps = 1, targetTime) {
oscport: busport,
address: '/c_set',
args: [bus_id, bus_value],
timestamp: ts,
timestamp: ts + offset,
});
console.log('bus message', msg);
// console.log('bus message', msg);
ws.send(msg);
// So they aren't sent with trigger messages
delete controls[k];
}
}
if (hap.hasOnset) {
if (hap.hasOnset()) {
const keyvals = Object.entries(controls).flat();
ws.send(JSON.stringify({ oschost, oscport, address: '/dirt/play', args: keyvals, timestamp: ts }));
ws.send(JSON.stringify({ oschost, oscport, address: '/dirt/play', args: keyvals, timestamp: ts + offset }));
}
}