Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat: Add openPortByName methods for input and output ports #32

Merged
merged 1 commit into from
Aug 9, 2024

Conversation

MarquisdeGeek
Copy link

Provide a name-oriented way to open ports, rather than an index, since the MIDI index is want to change.

@Julusian Julusian changed the title Add openPortByName methods for input and output ports feat: Add openPortByName methods for input and output ports Aug 9, 2024
@Julusian Julusian merged commit b0219ea into Julusian:master Aug 9, 2024
11 checks passed
@MeestorX
Copy link

MeestorX commented Nov 7, 2024

You may have issues with this code, in the event that there are 2 devices with the same name. In my code, a number is added to the name if there is more than one. e.g. Uno-MIDI-1, Uno-MIDI-2 etc. (Not my idea, I think that was in the original code)
https://github.com/bitfocus/companion-module-generic-midi/blob/445eeeb1742d6bee93dd1b3b5ea4dc4f89c39a30/src/midi/midi.ts#L135-L167

@MarquisdeGeek
Copy link
Author

I was pondering something similar - should/could openPortByName happen in two passes: first, check for an exact match, and secondly for an name.includes match?

@MeestorX
Copy link

MeestorX commented Nov 7, 2024

In my case, I just scan for all the names when opening and make a list of the names and match them with the id, then when doing the actual open, match the name and use the matching id. (again, not my idea, but it seems to work well)
https://github.com/bitfocus/companion-module-generic-midi/blob/445eeeb1742d6bee93dd1b3b5ea4dc4f89c39a30/src/midi/midi.ts#L99-L118

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants