Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Commit 4733bce

Browse files
authored
Test for open MIDI port (#264)
1 parent 70374d2 commit 4733bce

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

nodecg-io-midi-input/extension/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ class MidiService extends ServiceBundle<MidiInputServiceConfig, MidiInputService
5555
this.nodecg.log.info(`Connecting to MIDI input device ${deviceName}.`);
5656
if (deviceName !== null) {
5757
const client = new easymidi.Input(deviceName);
58-
this.nodecg.log.info(`Successfully connected to MIDI input device ${deviceName}.`);
59-
return success(client);
60-
} else {
61-
return error("Could not connect to the configured device!");
58+
if (client.isPortOpen()) {
59+
this.nodecg.log.info(`Successfully connected to MIDI input device ${deviceName}.`);
60+
return success(client);
61+
}
6262
}
63+
return error("Could not connect to the configured device!");
6364
}
6465
}
6566

nodecg-io-midi-input/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"typescript": "^4.2.4"
4242
},
4343
"dependencies": {
44-
"easymidi": "^2.0.4",
44+
"easymidi": "^2.1.0",
4545
"nodecg-io-core": "^0.2.0"
4646
}
4747
}

nodecg-io-midi-output/extension/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ class MidiService extends ServiceBundle<MidiOutputServiceConfig, MidiOutputServi
5555
this.nodecg.log.info(`Connecting to MIDI output device ${deviceName}.`);
5656
if (deviceName !== null) {
5757
const client = new easymidi.Output(deviceName);
58-
this.nodecg.log.info(`Successfully connected to MIDI output device ${deviceName}.`);
59-
return success(client);
60-
} else {
61-
return error("Could not connect to the configured device!");
58+
if (client.isPortOpen()) {
59+
this.nodecg.log.info(`Successfully connected to MIDI output device ${deviceName}.`);
60+
return success(client);
61+
}
6262
}
63+
return error("Could not connect to the configured device!");
6364
}
6465
}
6566

nodecg-io-midi-output/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"typescript": "^4.2.4"
4242
},
4343
"dependencies": {
44-
"easymidi": "^2.0.4",
44+
"easymidi": "^2.1.0",
4545
"nodecg-io-core": "^0.2.0"
4646
}
4747
}

0 commit comments

Comments
 (0)