Skip to content

Commit

Permalink
feat: Add openPortByName methods for input and output ports (#32)
Browse files Browse the repository at this point in the history
Co-authored-by: Steven Goodwin <marquisdegeek@gmail.com>
  • Loading branch information
MarquisdeGeek and Steven Goodwin authored Aug 9, 2024
1 parent c1d16f5 commit b0219ea
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions midi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export class Input extends EventEmitter {
ignoreTypes(sysex: boolean, timing: boolean, activeSensing: boolean): void;
/** Open the specified input port */
openPort(port: number): void;
/** Open the specified input port */
openPortByName(name: string): void;
/**
* Instead of opening a connection to an existing MIDI device, on Mac OS X
* and Linux with ALSA you can create a virtual device that other software
Expand Down Expand Up @@ -64,6 +66,8 @@ export class Output {
isPortOpen(): boolean
/** Open the specified output port */
openPort(port: number): void;
/** Open the specified output port */
openPortByName(name: string): void;
/**
* Instead of opening a connection to an existing MIDI device, on Mac OS X
* and Linux with ALSA you can create a virtual device that other software
Expand Down
16 changes: 16 additions & 0 deletions midi.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ class Input extends EventEmitter {
openPort(port) {
return this.input.openPort(port)
}
openPortByName(name) {
for(let port=0; port<this.input.getPortCount(); ++port) {
if (name === this.input.getPortName(port)) {
return this.input.openPort(port);
}
}
return undefined;
}
openVirtualPort(port) {
return this.input.openVirtualPort(port)
}
Expand Down Expand Up @@ -79,6 +87,14 @@ class Output {
openPort(port) {
return this.output.openPort(port)
}
openPortByName(name) {
for(let port=0; port<this.output.getPortCount(); ++port) {
if (name === this.output.getPortName(port)) {
return this.output.openPort(port);
}
}
return undefined;
}
openVirtualPort(port) {
return this.output.openVirtualPort(port)
}
Expand Down

0 comments on commit b0219ea

Please sign in to comment.