osc timing now hopefully works everywhere
This commit is contained in:
parent
0c726d835d
commit
c8e9fe519f
3 changed files with 9 additions and 11 deletions
|
|
@ -7,9 +7,12 @@ const latency = 0.1;
|
|||
|
||||
Pattern.prototype.osc = function () {
|
||||
return this._withEvent((event) => {
|
||||
const onTrigger = (time, event, startedAt) => {
|
||||
const onTrigger = (time, event, currentTime) => {
|
||||
// time should be audio time of onset
|
||||
// currentTime should be current time of audio context (slightly before time)
|
||||
const keyvals = Object.entries(event.value).flat();
|
||||
const ts = Math.floor(startedAt + (time + latency) * 1000);
|
||||
const offset = (time - currentTime + latency) * 1000;
|
||||
const ts = Math.floor(Date.now() + offset);
|
||||
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