mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-22 11:08:35 +00:00
workaround for osc-js timestamp bug, reduce latency
This commit is contained in:
parent
4ef70d2a15
commit
ac01a621be
@ -3,17 +3,18 @@ import { Pattern, isPattern } from '@strudel.cycles/core/strudel.mjs';
|
|||||||
|
|
||||||
const comm = new OSC();
|
const comm = new OSC();
|
||||||
comm.open();
|
comm.open();
|
||||||
|
// TODO - get startTime from scheduler
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
const latency = 0.2;
|
const latency = 0.1;
|
||||||
|
|
||||||
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 ts = startTime + ((time+latency)*1000);
|
const ts = Math.floor(startTime + ((time + latency) * 1000));
|
||||||
const message = new OSC.Message('/dirt/play',...keyvals);
|
const message = new OSC.Message('/dirt/play',...keyvals);
|
||||||
const bundle = new OSC.Bundle([message], ts)
|
const bundle = new OSC.Bundle([message], ts);
|
||||||
|
bundle.timestamp(ts); // workaround for https://github.com/adzialocha/osc-js/issues/60
|
||||||
comm.send(bundle);
|
comm.send(bundle);
|
||||||
};
|
};
|
||||||
return event.setContext({ ...event.context, onTrigger });
|
return event.setContext({ ...event.context, onTrigger });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user