I\'ve been trying to use AVAudioEngine to schedule multiple audio files to play in perfect sync, but when listening to the output there seems to be a very slight delay betwe
I used Apple developer support ticket for my own problems with AVAudioEngine in which one problem was (is) exactly the same as yours. I got this code to try:
AudioTimeStamp myAudioQueueStartTime = {0};
UInt32 theNumberOfSecondsInTheFuture = 5;
Float64 hostTimeFreq = CAHostTimeBase::GetFrequency();
UInt64 startHostTime = CAHostTimeBase::GetCurrentTime()+theNumberOfSecondsInTheFuture*hostTimeFreq;
myAudioQueueStartTime.mFlags = kAudioTimeStampHostTimeValid;
myAudioQueueStartTime.mHostTime = startHostTime;
AVAudioTime *time = [AVAudioTime timeWithAudioTimeStamp:&myAudioQueueStartTime sampleRate:_file.processingFormat.sampleRate];
Aside from scheduling play in Skynet era instead of 5 seconds in the future, it still didn't sync two AVAudioPlayerNodes (when I switched GetCurrentTime() for some arbitrary value to actually manage to play the nodes).
So not being able to sync two and more nodes together is a bug (confirmed by Apple support). Generally, if you don't have to use something that was introduced with AVAudioEngine (and you don't know how to translate it into AUGraph), I advise to use AUGraph instead. It's a bit more overhead to implement but you have more control over it.