mirror of
https://codeberg.org/uzu/strudel
synced 2026-11-23 17:11:35 -05:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6a85f711d2 |
@@ -1,23 +0,0 @@
|
||||
In line with [our humane policy](POLICY.md), code and documentation
|
||||
should not be written by LLM agents. To this end, agents should not
|
||||
edit the codebase or make any commits that are intended to be
|
||||
contributed upstream. Likewise, LLM output should not be pasted into
|
||||
issues, comments, pull requests and so on.
|
||||
|
||||
A contributor's personal use of LLMs and related technology is their
|
||||
own business, whether for research, analysis, bug discovery or other
|
||||
assistive technology, so long as the output is not included in any
|
||||
contributions to our projects.
|
||||
|
||||
Strudel is AGPL licensed, and so any code integrated with it also
|
||||
comes under that license. This should be carefully considered before
|
||||
distributing software integrated with strudel, including making it
|
||||
available over a network.
|
||||
|
||||
Strudel has purposefully moved away from github.com, as a closed
|
||||
source platform with ethical issues. Please do not fork strudel back
|
||||
to that platform, or similar corporate platforms.
|
||||
|
||||
Projects using strudel must not use "strudel" in their name, unless
|
||||
they are 'official' projects, or have the blessing of the strudel
|
||||
community.
|
||||
+56
-25
@@ -57,9 +57,8 @@ export function parseControlsFromHap(hap, cps) {
|
||||
}
|
||||
|
||||
let timeOrigin = performance.timeOrigin;
|
||||
export async function oscOutput(hap, targetTime, cps = 1) {
|
||||
const ws = await connect();
|
||||
|
||||
function getOscTimestamp(targetTime) {
|
||||
const timeMs = getClockBridge().getPerformanceTime(targetTime);
|
||||
if (!timeMs) {
|
||||
logger('[osc] clockbridge not ready');
|
||||
@@ -73,44 +72,73 @@ export async function oscOutput(hap, targetTime, cps = 1) {
|
||||
// shift time after microsleep
|
||||
timeOrigin -= deprivation;
|
||||
}
|
||||
const ts = timeOrigin + timeMs;
|
||||
return timeOrigin + timeMs;
|
||||
}
|
||||
|
||||
export async function oscOutput(hap, targetTime, cps = 1) {
|
||||
const ws = await connect();
|
||||
const ts = getOscTimestamp(targetTime);
|
||||
if (!ts) {
|
||||
return;
|
||||
}
|
||||
|
||||
const controls = parseControlsFromHap(hap, cps);
|
||||
const keyvals = Object.entries(controls).flat();
|
||||
const msg = { address: '/dirt/play', args: keyvals, timestamp: ts };
|
||||
|
||||
if ('oschost' in hap.value) {
|
||||
msg.oschost = hap.value.oschost;
|
||||
}
|
||||
if ('oscport' in hap.value) {
|
||||
msg.oscport = hap.value.oscport;
|
||||
}
|
||||
|
||||
ws.send(JSON.stringify(msg));
|
||||
}
|
||||
|
||||
export async function superdirtTrigger(hap, currentTime, cps = 1, targetTime) {
|
||||
export async function superdirtOutput(hap, targetTime, cps = 1) {
|
||||
const ws = await connect();
|
||||
const ts = getOscTimestamp(targetTime);
|
||||
if (!ts) {
|
||||
return;
|
||||
}
|
||||
|
||||
const controls = parseControlsFromHap(hap, cps);
|
||||
const ts = collator.calculateTimestamp(currentTime, targetTime) * 1000;
|
||||
|
||||
let oschost = '127.0.0.1';
|
||||
let oscport = 57120;
|
||||
let bushost = oschost;
|
||||
let busport = 57110;
|
||||
const oschost = hap.value.oschost ?? '127.0.0.1';
|
||||
const oscport = hap.value.oscport ?? 57120;
|
||||
const bushost = oschost;
|
||||
const busport = 57110;
|
||||
|
||||
for (const [k, v] of Object.entries(controls)) {
|
||||
if (k.startsWith('^')) {
|
||||
const bus_idval = v;
|
||||
const msg = JSON.stringify({
|
||||
oschost: bushost,
|
||||
oscport: busport,
|
||||
address: '/c_set',
|
||||
args: bus_idval,
|
||||
timestamp: ts,
|
||||
});
|
||||
// console.log('bus message', msg);
|
||||
ws.send(msg);
|
||||
// So they aren't sent with trigger messages
|
||||
delete controls[k];
|
||||
// send SuperDirt bus/control messages first
|
||||
for (const [key, busIdVal] of Object.entries(controls)) {
|
||||
if (key.startsWith('^')) {
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
oschost: bushost,
|
||||
oscport: busport,
|
||||
address: '/c_set',
|
||||
args: busIdVal,
|
||||
timestamp: ts,
|
||||
}),
|
||||
);
|
||||
// so they aren't sent with trigger messages
|
||||
delete controls[key];
|
||||
}
|
||||
}
|
||||
|
||||
// only trigger samples on haps that actually begin here
|
||||
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,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,4 +156,7 @@ export const osc = register('osc', (pat) => {
|
||||
ensureMinimalOutput();
|
||||
return pat.onSchedule(oscOutput);
|
||||
});
|
||||
export const superdirt = register('superdirt', (pat) => pat._processParts().onTrigger(superdirtTrigger));
|
||||
export const superdirt = register('superdirt', (pat) => {
|
||||
ensureMinimalOutput();
|
||||
return pat._processParts().onSchedule(superdirtOutput);
|
||||
});
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
/* import { tauriOscOutput } from '../desktopbridge/oscbridge.mjs';
|
||||
import { isTauri } from '../desktopbridge/utils.mjs'; */
|
||||
import { oscOutput } from './osc.mjs';
|
||||
// const output = /* isTauri() ? tauriOscOutput : */ oscOutput;
|
||||
|
||||
const output = /* isTauri() ? tauriOscOutput : */ oscOutput;
|
||||
|
||||
export const superdirtOutput = (hap, targetTime, cps) => output(hap, targetTime, cps);
|
||||
export { superdirtOutput } from './osc.mjs';
|
||||
|
||||
Reference in New Issue
Block a user