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

Test for open MIDI port #264

Merged
merged 2 commits into from
Oct 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions nodecg-io-midi-input/extension/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ class MidiService extends ServiceBundle<MidiInputServiceConfig, MidiInputService
this.nodecg.log.info(`Connecting to MIDI input device ${deviceName}.`);
if (deviceName !== null) {
const client = new easymidi.Input(deviceName);
this.nodecg.log.info(`Successfully connected to MIDI input device ${deviceName}.`);
return success(client);
} else {
return error("Could not connect to the configured device!");
if (client.isPortOpen()) {
this.nodecg.log.info(`Successfully connected to MIDI input device ${deviceName}.`);
return success(client);
}
}
return error("Could not connect to the configured device!");
}
}

Expand Down
2 changes: 1 addition & 1 deletion nodecg-io-midi-input/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"typescript": "^4.2.4"
},
"dependencies": {
"easymidi": "^2.0.4",
"easymidi": "^2.1.0",
"nodecg-io-core": "^0.2.0"
}
}
9 changes: 5 additions & 4 deletions nodecg-io-midi-output/extension/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ class MidiService extends ServiceBundle<MidiOutputServiceConfig, MidiOutputServi
this.nodecg.log.info(`Connecting to MIDI output device ${deviceName}.`);
if (deviceName !== null) {
const client = new easymidi.Output(deviceName);
this.nodecg.log.info(`Successfully connected to MIDI output device ${deviceName}.`);
return success(client);
} else {
return error("Could not connect to the configured device!");
if (client.isPortOpen()) {
this.nodecg.log.info(`Successfully connected to MIDI output device ${deviceName}.`);
return success(client);
}
}
return error("Could not connect to the configured device!");
}
}

Expand Down
2 changes: 1 addition & 1 deletion nodecg-io-midi-output/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"typescript": "^4.2.4"
},
"dependencies": {
"easymidi": "^2.0.4",
"easymidi": "^2.1.0",
"nodecg-io-core": "^0.2.0"
}
}