mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-22 11:08:35 +00:00
try to send osc as timestamped bundle
This commit is contained in:
parent
ba095d8e7f
commit
0bfbd87bbf
@ -1,15 +1,18 @@
|
|||||||
import OSC from './node_modules/osc-js/lib/osc.js';
|
import OSC from './node_modules/osc-js/lib/osc.js';
|
||||||
import { Pattern, isPattern } from '@strudel.cycles/core/strudel.mjs';
|
import { Pattern, isPattern } from '@strudel.cycles/core/strudel.mjs';
|
||||||
//import {OSC} from 'osc-js';
|
|
||||||
|
|
||||||
const comm = new OSC();
|
const comm = new OSC();
|
||||||
comm.open();
|
comm.open();
|
||||||
|
const startTime = Date.now();
|
||||||
|
const latency = 0.1 * 1000;
|
||||||
|
|
||||||
Pattern.prototype.osc = function () {
|
Pattern.prototype.osc = function () {
|
||||||
return this._withEvent((event) => {
|
return this._withEvent((event) => {
|
||||||
const onTrigger = (time, event) => {
|
const onTrigger = (time, event) => {
|
||||||
|
console.log(time);
|
||||||
const keyvals = Object.entries(event.value).flat();
|
const keyvals = Object.entries(event.value).flat();
|
||||||
const message = new OSC.Message('/dirt/play', ...keyvals);
|
const ts = startTime + (time*1000);
|
||||||
|
const message = new OSC.Message('/dirt/play', ts, ...keyvals);
|
||||||
comm.send(message);
|
comm.send(message);
|
||||||
};
|
};
|
||||||
return event.setContext({ ...event.context, onTrigger });
|
return event.setContext({ ...event.context, onTrigger });
|
||||||
|
|||||||
@ -28,10 +28,13 @@ console.log('websocket server running on port', config.wsServer.port);
|
|||||||
|
|
||||||
// listen for messages from the client
|
// listen for messages from the client
|
||||||
osc.on('*', (m) => {
|
osc.on('*', (m) => {
|
||||||
// forward message to supercollider??
|
console.log("hmm!");
|
||||||
|
const ts = m.args.shift();
|
||||||
const message = new OSC.Message(m.address, ...m.args);
|
const message = new OSC.Message(m.address, ...m.args);
|
||||||
osc.send(message); // will it even be received??
|
console.log(m.args);
|
||||||
console.log('forward:', m.address, m.args);
|
const bundle = new OSC.Bundle([message], new Date(ts))
|
||||||
|
osc.send(bundle);
|
||||||
|
console.log('forward:', bundle);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user