fixes + tidying

This commit is contained in:
alex
2025-10-24 20:48:35 +01:00
parent 77a7a148f0
commit 1834d689ef
4 changed files with 16 additions and 11 deletions
+9
View File
@@ -72,6 +72,15 @@ export function registerControl(names, ...aliases) {
return bag;
}
// Constructs a superdirt effect bus control
const bus = register('bus', function (busid, control_name, busval, pat) {
return pat[control_name]('c' + busid).withValue((val) => {
const newval = { ...val };
newval['^' + control_name] = [busid, busval];
return newval;
});
});
/**
* Select a sound / sample by name. When using mininotation, you can also optionally supply 'n' and 'gain' parameters
* separated by ':'.
+2 -2
View File
@@ -61,13 +61,13 @@ export class Cyclist {
haps.forEach((hap) => {
if (hap.hasOnset() || hap.context.processParts) {
const targetTime =
(hap.whole.begin - this.num_cycles_at_cps_change) / this.cps + this.seconds_at_cps_change + latency;
(hap.part.begin - this.num_cycles_at_cps_change) / this.cps + this.seconds_at_cps_change + latency;
const duration = hap.duration / this.cps;
// the following line is dumb and only here for backwards compatibility
// see https://codeberg.org/uzu/strudel/pulls/1004
const deadline = targetTime - phase;
// this onTrigger has another signature
onTrigger?.(hap, deadline, duration, this.cps, targetTime, begin);
onTrigger?.(hap, deadline, duration, this.cps, targetTime);
if (hap.value.cps !== undefined && this.cps != hap.value.cps) {
this.cps = hap.value.cps;
this.num_ticks_since_cps_change = 0;
+5 -8
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, queryBegin) {
export async function superdirtTrigger(hap, currentTime, cps = 1, targetTime) {
const ws = await connect();
const controls = parseControlsFromHap(hap, cps);
const ts = collator.calculateTimestamp(currentTime, targetTime) * 1000;
@@ -79,16 +79,13 @@ export async function superdirtTrigger(hap, currentTime, cps = 1, targetTime, qu
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 bus_idval = v;
const msg = JSON.stringify({
oschost: bushost,
oscport: busport,
address: '/c_set',
args: [bus_id, bus_value],
timestamp: ts + offset,
args: bus_idval,
timestamp: ts,
});
// console.log('bus message', msg);
ws.send(msg);
@@ -99,7 +96,7 @@ export async function superdirtTrigger(hap, currentTime, cps = 1, targetTime, qu
if (hap.hasOnset()) {
const keyvals = Object.entries(controls).flat();
ws.send(JSON.stringify({ oschost, oscport, address: '/dirt/play', args: keyvals, timestamp: ts + offset }));
ws.send(JSON.stringify({ oschost, oscport, address: '/dirt/play', args: keyvals, timestamp: ts }));
}
}
-1
View File
@@ -48,7 +48,6 @@ wss.on('connection', (ws) => {
if ('timestamp' in data) {
msg = { timeTag: osc.timeTag(0, data['timestamp']), packets: [msg] };
}
console.log(msg, oschost, oscport);
udpPort.send(msg, oschost, oscport);
} catch (err) {
console.error('Error parsing message:', err);