Skip to content

Commit

Permalink
sync start / stop automatically too
Browse files Browse the repository at this point in the history
  • Loading branch information
felixroos committed Sep 27, 2023
1 parent dea1c31 commit f11462b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/midi/midi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ function getDevice(output, outputs) {
return IACOutput ?? outputs[0];
}

// send start/stop messages to outputs when repl starts/stops
if (typeof window !== 'undefined') {
window.addEventListener('message', (e) => {
if (!WebMidi?.enabled) {
return;
}
if (e.data === 'strudel-stop') {
WebMidi.outputs.forEach((output) => output.sendStop());
} else if (e.data === 'strudel-start') {
WebMidi.outputs.forEach((output) => output.sendStart());
}
});
}

Pattern.prototype.midi = function (output) {
if (isPattern(output)) {
throw new Error(
Expand Down

0 comments on commit f11462b

Please sign in to comment.