-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get Port Number after calling open_midiinput or open_midioutput? #205
Comments
Alas, it doesn't work that way. Port numbers are not guaranteed or even expected to stay the same. They change as MIDI devices get added or disconnected. That's one of the main flaws of the RtMidi API (it is not alone in having that flaw, though). The best strategy is probably to save (a substring) of the port name. |
BTW, |
Thx for the quick response. Quick and Dirty if totally fine with me. Programming is just a hobby of mine and i only code if i need a tool for myself. I'm writing a hacky little tool to trick the Mackie Control Implementation of TotalMix from RME to get absolute Midi Mapping for some functions. They say they are currently working on a rewrite of their Midi Implementation. Too long for me to wait, but the script might get suddenly (and hopefully) obsolete when and if they really implement Midi Learn functionality to TotalMix. My usecase for the quick and dirty saving of the Midi Setup is just, so you don't have to repeat the whole setup procedure when you restart the script and nothing has changed with the Midi Ports. I also found that on windows you get the Port Number with the namestring of the open_midiport function and on Mac you don't. - Is that expected and stable? But anyway, as i will use pyinstaller and freeze the source for an one folder distro i might as well hack into midiutils.py. |
You mean the name includes some kind of number? That is entirely dependent on the OS-dependant MIDI backend and its USB MIDI driver. Unfortunately this makes MIDI device names change potentially when dis- and reconnecting them. That's one reason why this part of the RtMid API is flawed. python-rtmidi does not (and can't) change that.
Just copy the implementation of |
I'm working on a way to save the Midi Setup and want to write the choosen Portnumbers to a txt file and when i recall i just pass it directly to open_midiinput(port) or open_midioutput(port).
I can add port to the return of open_midiport in midiutils.py and get the Portnumber this way. But i really don't want to change anything inside the module installed via pip.
The text was updated successfully, but these errors were encountered: