Last active
August 29, 2015 14:12
-
-
Save johnty/fe7948c8c92a3f78cf98 to your computer and use it in GitHub Desktop.
midi port name search/connect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int portInIndex = -1; | |
int portOutIndex = -1; | |
// print input ports to console | |
midiIn.listPorts(); // via instance | |
//ofxMidiIn::listPorts(); // via static as well | |
if (midiIn.getNumPorts()) { | |
for (int i=0; i<midiIn.getNumPorts(); i++) { | |
string pname = midiIn.getPortName(i); | |
if (ofStringTimesInString(pname, "ICubeX")) { | |
printf("port exists!\n"); | |
portInIndex = i; | |
} | |
} | |
} | |
if (ofxMidiOut::getNumPorts()) { | |
for (int i=0; i<ofxMidiOut::getNumPorts(); i++) { | |
string pname = ofxMidiOut::getPortName(i); | |
if (ofStringTimesInString(pName, "ICubeX")) { | |
portOutIndex = i; //note: there is a very small chance that when using multiple digitizers | |
// we can have two virtual devices but the in/out port indicies are mixed up? | |
// this is highly unlikely due to use case scenario, but this note is left here | |
// just in case... | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment