Skip to content
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

Reordering reconnected MIDI devices #82

Open
vooku opened this issue Sep 30, 2021 · 2 comments
Open

Reordering reconnected MIDI devices #82

vooku opened this issue Sep 30, 2021 · 2 comments

Comments

@vooku
Copy link

vooku commented Sep 30, 2021

Hi, I've been using ofxMidi happily in my app vooku/skinny but come across this problem when implementing GUI for MIDI devices. I specifically encountered this on Windows.

When I connect multiple devices, they get a number appended to their name.

image

However if I disconnect one, the numbers get redistributed.

image

This poses a problem when I try to access the same device again (to disconnect), but have no persistent handle. Have I missed something? Is this because of one of the underlying libraries?

The MIDI input still works however, so there must be something below the layers that I have looked into.

@danomatika
Copy link
Owner

This addon was originally written with a simple "open some ports and run for awhile" approach without any deeper event handling. You are running into the need for this now. :)

ofxMidi doesn't do this automatically for you, but it should be possible. You would basically need to detect when a device is disconnected, then manually close/reopen all ports, possibly using the previous device name to find it's new index. I would suggest looking into the latest version of RtMidi which may have added some functionality to help, then we can look into strategies to add support within ofxMidi, at the very least some extra even handling:

https://www.music.mcgill.ca/~gary/rtmidi/

Note: The iOS implementation using PGMidi provides an ofxMidiConnectionListener base class for receiving connection add/remove events, but this is leveraging the CoreMidi event system which works differently on other platforms.

https://github.com/danomatika/ofxMidi/blob/master/src/ofxMidi.h#L18

@vooku
Copy link
Author

vooku commented May 29, 2022

Thanks for the tips, I'll look into it when I get the opportunity

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

No branches or pull requests

2 participants