fix absolute time
This commit is contained in:
parent
c3b15fffa4
commit
86b1e992a1
3 changed files with 12 additions and 9 deletions
|
|
@ -1,17 +1,15 @@
|
|||
import OSC from './node_modules/osc-js/lib/osc.js';
|
||||
import { Pattern, isPattern } from '@strudel.cycles/core/strudel.mjs';
|
||||
import { Pattern } from '@strudel.cycles/core/strudel.mjs';
|
||||
|
||||
const comm = new OSC();
|
||||
comm.open();
|
||||
// TODO - get startTime from scheduler
|
||||
const startTime = Date.now();
|
||||
const latency = 0.1;
|
||||
|
||||
Pattern.prototype.osc = function () {
|
||||
return this._withEvent((event) => {
|
||||
const onTrigger = (time, event) => {
|
||||
const onTrigger = (time, event, startedAt) => {
|
||||
const keyvals = Object.entries(event.value).flat();
|
||||
const ts = Math.floor(startTime + ((time + latency) * 1000));
|
||||
const ts = Math.floor(startedAt + (time + latency) * 1000);
|
||||
const message = new OSC.Message('/dirt/play', ...keyvals);
|
||||
const bundle = new OSC.Bundle([message], ts);
|
||||
bundle.timestamp(ts); // workaround for https://github.com/adzialocha/osc-js/issues/60
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue