Skip to content

Commit

Permalink
send start with accurate timing
Browse files Browse the repository at this point in the history
  • Loading branch information
felixroos committed Sep 27, 2023
1 parent f11462b commit 4eb0a7b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/midi/midi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,8 @@ if (typeof window !== 'undefined') {
}
if (e.data === 'strudel-stop') {
WebMidi.outputs.forEach((output) => output.sendStop());
} else if (e.data === 'strudel-start') {
WebMidi.outputs.forEach((output) => output.sendStart());
}
// cannot start here, since we have no timing info, see sendStart below
});
}

Expand Down Expand Up @@ -150,6 +149,10 @@ Pattern.prototype.midi = function (output) {
const scaled = Math.round(ccv * 127);
device.sendControlChange(ccn, scaled, midichan, { time: timeOffsetString });
}
if (hap.whole.begin + 0 === 0) {
// we need to start here because we have the timing info
device.sendStart({ time: timeOffsetString });
}
if (['clock', 'midiClock'].includes(midicmd)) {
device.sendClock({ time: timeOffsetString });
} else if (['start'].includes(midicmd)) {
Expand Down

0 comments on commit 4eb0a7b

Please sign in to comment.