我在midi同步方面遇到了问题。在syntheticbits.com中的帖子之后,我使用了PGMidi类。同步工作,但不断转换到1-2 bpm。
下面是我使用的代码:
- (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];
}请告诉我如何获得清晰的同步。
https://stackoverflow.com/questions/9739756
复制相似问题