mirror of
https://codeberg.org/uzu/strudel
synced 2026-09-05 22:58:09 -04:00
fixes + tidying
This commit is contained in:
@@ -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 ':'.
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 }));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user