미디 동기화에 문제가 있습니다. syntheticbits.com의 게시물에 이어 PGMidi 클래스를 사용합니다. 동기화는 작동하지만 지속적으로 1-2bpm으로 이동합니다.CoreMIDI : 단색 미디 동기화
- (void)sendMidiClockInMidiThread {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[lock lock];
const int64_t kOneMillion = 1000 * 1000;
const UInt8 tick[] = { 0xF8 };
// Calculate tick time
// returns sample for sixteen note (5512 if current bpm is 120)
SInt32 sixteen = AGGetSamples_SixteensWithoutSwing(_grid, 1.0);
UInt64 tickTime = (sixteen/6) * kOneMillion;
int tickLatency = 0;
// Send ticks messages
for (int i = 0; i < 6; ++i) {
int beginTime = clock();
hostTime = hostTime + (tickTime - tickLatency);
[self.midi sendBytes:tick size:sizeof(tick) atTime:hostTime];
int endTime = clock();
tickLatency = endTime - beginTime;
}
[lock unlock];
[pool drain];
}
방법 명확한 동기를 얻는 방법을 가르쳐주세요 : 여기
은 내가 사용하는 코드입니다.