try sending osc in timestamped bundle with added latency

This commit is contained in:
alex 2022-03-29 17:03:30 +01:00
parent 0bfbd87bbf
commit d0d19778a4

View File

@ -4,16 +4,17 @@ import { Pattern, isPattern } from '@strudel.cycles/core/strudel.mjs';
const comm = new OSC();
comm.open();
const startTime = Date.now();
const latency = 0.1 * 1000;
const latency = 0.2;
Pattern.prototype.osc = function () {
return this._withEvent((event) => {
const onTrigger = (time, event) => {
console.log(time);
const keyvals = Object.entries(event.value).flat();
const ts = startTime + (time*1000);
const message = new OSC.Message('/dirt/play', ts, ...keyvals);
comm.send(message);
const ts = startTime + ((time+latency)*1000);
const message = new OSC.Message('/dirt/play',...keyvals);
const bundle = new OSC.Bundle([message], ts)
comm.send(bundle);
};
return event.setContext({ ...event.context, onTrigger });
});