Skip to content

Commit

Permalink
Disregard incoming messages after WebMIDI has been cycled on/off
Browse files Browse the repository at this point in the history
Unfortunately, unregistering the event handlers does nothing to stop incoming
incoming MIDI messages from external devices from being received and handled,
nor does it seem to be possible to stop the system from registering and
working with newly connected devices. Just ignoring these messages as long as
"useWebMidi" is false seems to be the best/only solution.
  • Loading branch information
broadwell committed Jan 20, 2022
1 parent a35c450 commit 8a6b9ef
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/components/WebMidi.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import { onMount } from "svelte";
import { clamp } from "../lib/utils";
import { midiInputs, midiOutputs } from "../stores";
import { midiInputs, midiOutputs, userSettings } from "../stores";
export let startNote;
export let stopNote;
Expand All @@ -27,7 +27,7 @@
};
const receiveMidiMsg = ({ data: [msgType, entity, value] }) => {
if (!entity) return;
if (!entity || !$userSettings.useWebMidi) return;
switch (msgType) {
case midiBytes.CONTROLLER:
Expand Down Expand Up @@ -87,12 +87,6 @@
midi.onstatechange = () => updatePorts(midi);
});
}
return () => {
$midiInputs.forEach((input) =>
input.removeEventListener("midimessage", receiveMidiMsg),
);
};
});
export { sendMidiMsg };
Expand Down

0 comments on commit 8a6b9ef

Please sign in to comment.