@@ -99,6 +99,49 @@ void readProc(const MIDIPacketList *newPackets, void *refCon,
99
99
}
100
100
#endif
101
101
102
+ DLLEXPORT int midiprobe (char * device )
103
+ {
104
+ #ifdef __APPLE__
105
+ int sourceIndex = 0 , destIndex = 0 ;
106
+ char * sourceName , * destName ;
107
+ CFStringRef displayName ;
108
+ char name [255 ];
109
+ void * conRef = NULL ;
110
+ int index ;
111
+
112
+ sourceName = strtok (device , ":" );
113
+ if (sourceName != NULL ) sourceIndex = -1 ;
114
+ for (index = 0 ; sourceName != NULL && index < MIDIGetNumberOfSources (); index ++ )
115
+ {
116
+ dest = MIDIGetSource (index );
117
+ MIDIObjectGetStringProperty (dest , kMIDIPropertyDisplayName , & displayName );
118
+ CFStringGetCString (displayName , name , 255 , kCFStringEncodingASCII );
119
+ if (strcmp (sourceName , name ) == 0 )
120
+ {
121
+ sourceIndex = index ;
122
+ break ;
123
+ }
124
+ }
125
+
126
+ destName = strtok (NULL , ":" );
127
+ if (destName != NULL ) destIndex = -1 ;
128
+ for (index = 0 ; destName != NULL && index < MIDIGetNumberOfDestinations (); index ++ )
129
+ {
130
+ dest = MIDIGetDestination (index );
131
+ MIDIObjectGetStringProperty (dest , kMIDIPropertyDisplayName , & displayName );
132
+ CFStringGetCString (displayName , name , 255 , kCFStringEncodingASCII );
133
+ if (strcmp (destName , name ) == 0 )
134
+ {
135
+ destIndex = index ;
136
+ break ;
137
+ }
138
+ }
139
+
140
+ return sourceIndex >= 0 && destIndex >= 0 ;
141
+ #endif
142
+ return 0 ;
143
+ }
144
+
102
145
DLLEXPORT void midiopen (char * device )
103
146
{
104
147
#ifdef __APPLE__
0 commit comments