I'm trying to create an internal MIDI clock in my app, but wanted to the clock could be seen in other apps by sending the clock messages to midi out nodes.
CAClockNew(0, &theClock);
syncMode = kCAClockSyncMode_Internal;
timeBase = kCAClockTimebase_HostTime;
tempoMap.beats = 4;
tempoMap.tempoBPM = 120.0f;
CAClockSetProperty(theClock,kCAClockProperty_SyncMode,sizeof(syncMode), &syncMode);
CAClockSetProperty(theClock,kCAClockProperty_InternalTimebase,sizeof(timeBase), &timeBase);
CAClockSetProperty(theClock,kCAClockProperty_TempoMap,sizeof(tempoMap), &tempoMap);
MIDIEndpointRef *sources;
int i, j;
ItemCount num_sources = MIDIGetNumberOfSources();
sources = (MIDIEndpointRef *)malloc(sizeof(MIDIEndpointRef) * num_sources);
j = 0;
for (i = 0; i < num_sources; i++) {
MIDIEndpointRef source;
source = MIDIGetSource(i);
sources[j++] = source;
}
CFArrayRef sourcesArray = CFArrayCreate(NULL, (void *)sources, j, NULL);
CAClockSetProperty(theClock,kCAClockProperty_MIDIClockDestinations,sizeof(sourcesArray), &sourcesArray);
CAClockStart(theClock);