diff --git a/src/lib/libmidi.dylib b/src/lib/libmidi.dylib index c4c3cb9..3c720a0 100755 Binary files a/src/lib/libmidi.dylib and b/src/lib/libmidi.dylib differ diff --git a/src/libmidi.c b/src/libmidi.c index 0892bc7..6af597d 100644 --- a/src/libmidi.c +++ b/src/libmidi.c @@ -99,6 +99,49 @@ void readProc(const MIDIPacketList *newPackets, void *refCon, } #endif +DLLEXPORT int midiprobe(char *device) +{ +#ifdef __APPLE__ + int sourceIndex = 0, destIndex = 0; + char *sourceName, *destName; + CFStringRef displayName; + char name[255]; + void *conRef = NULL; + int index; + + sourceName = strtok(device, ":"); + if (sourceName != NULL) sourceIndex = -1; + for (index = 0; sourceName != NULL && index < MIDIGetNumberOfSources(); index++) + { + dest = MIDIGetSource(index); + MIDIObjectGetStringProperty(dest, kMIDIPropertyDisplayName, &displayName); + CFStringGetCString(displayName, name, 255, kCFStringEncodingASCII); + if (strcmp(sourceName, name) == 0) + { + sourceIndex = index; + break; + } + } + + destName = strtok(NULL, ":"); + if (destName != NULL) destIndex = -1; + for (index = 0; destName != NULL && index < MIDIGetNumberOfDestinations(); index++) + { + dest = MIDIGetDestination(index); + MIDIObjectGetStringProperty(dest, kMIDIPropertyDisplayName, &displayName); + CFStringGetCString(displayName, name, 255, kCFStringEncodingASCII); + if (strcmp(destName, name) == 0) + { + destIndex = index; + break; + } + } + + return sourceIndex >= 0 && destIndex >= 0; +#endif + return 0; +} + DLLEXPORT void midiopen(char *device) { #ifdef __APPLE__ diff --git a/src/midi.jl b/src/midi.jl index 70b0b7d..53c60de 100644 --- a/src/midi.jl +++ b/src/midi.jl @@ -3,6 +3,14 @@ module midi const libmidi = joinpath(@__DIR__, Sys.KERNEL == :NT ? "lib/libmidi.dll" : Sys.KERNEL == :Linux ? "lib/libmidi.so" : "lib/libmidi.dylib") +function midiprobe(device) + ret = ccall((:midiprobe, libmidi), + Int32, + (Ptr{UInt8}, ), + device) +end +export midiprobe + function midiopen(device="") ccall((:midiopen, libmidi), Nothing,