how do I synchronize playback to AVAudioRecorder start record time? Can I assume AVAudioRecorder uses the clock from CMClockGetHostTimeClock?
CMTime referenceTime = CMTimeAdd(CMClockGetTime(self.player.masterClock), CMTimeMakeWithSeconds(2, NSECPERSEC)); //start playback and record 2 seconds after.
[self.player setRate:1.0 time:kCMTimeZero atHostTime:referenceTime];
CMTime syncPTS = CMSyncConvertTime(referenceTime, self.player.masterClock, CMClockGetHostTimeClock());
[self.audioRecorder recordAtTime:CMTimeGetSeconds(syncPTS) forDuration:30]; //audioRecorder is an instance of AVAudioRecorder
Post
Replies
Boosts
Views
Activity
Is this how you would calculate the total roundtrip latency as you described with AVAudioSession? ([AVAudioSession sharedInstance].IOBufferDuration + [AVAudioSession sharedInstance].inputLatency + [AVAudioSession sharedInstance].outputLatency);My understanding is that both inputLatency and outputLatency accounts for device and stream latency. I can find how to get the input and output safety offsets in iOS. Also, should add the IOBufferDuration twice for the roundtrip? One for output and one for input?