Skip to content

Commit

Permalink
Be less picky about MIDI port names, closes wntrblm/Castor_and_Pollux#21
Browse files Browse the repository at this point in the history
  • Loading branch information
theacodes committed Sep 8, 2024
1 parent 96e1339 commit 37a3981
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/scripts/audio/midi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,17 @@ export class MIDI {

async connect() {
let access = await navigator.requestMIDIAccess({ sysex: true });
const searchName = this.portName.toLowerCase();

for (const port of access.inputs.values()) {
if (port.name === this.portName) {
const name = port.name?.toLowerCase() ?? "";
if (name.includes(searchName)) {
this.input = port;
}
}
for (const port of access.outputs.values()) {
if (port.name === this.portName) {
const name = port.name?.toLowerCase() ?? "";
if (name.includes(searchName)) {
this.output = port;
}
}
Expand Down

0 comments on commit 37a3981

Please sign in to comment.