[Portaudio] Reported latency

Erik Ronström erik.ronstrom at doremir.com
Mon Dec 7 18:19:17 EST 2015


Yeah, but I don’t want to have my users perform a latency test before they can start using the application…

Erik




> 7 dec 2015 kl. 23:57 skrev ericzhang at gmail.com:
> 
> If you have the audio, you can perform a simple cross-correlation analysis and find the sample delay basically exactly.
> 
> -- 
> 
> Sent with Airmail
> 
> On December 7, 2015 at 5:48:59 PM, Erik Ronström (erik.ronstrom at doremir.com <mailto:erik.ronstrom at doremir.com>) wrote:
> 
>> Hi List,
>> 
>> (Apologies if this has been asked before, but I haven’t yet found an answer by searching the web)
>> 
>> I want to synchronize recorded audio with the track that was played back during recording. As far as I understand, this means offsetting the recorded audio by (inputLatency + outputLatency). The problem is that I cannot make sense of the latency values that PortAudio reports.
>> 
>> There seems to be four latency values of interest here: the suggested latency (set by PaStreamParameters), the ”actual” latency (as reported by PaStreamInfo), the difference between inputBufferAdcTime and outputBufferDacTime in PaStreamCallback, and finally, the ”real-world” actual latency.
>> 
>> To get the ”real-world” latency I recorded the backtrack playing from the computer speaker directly into the internal microphone, and looked at the audio file. I did this several times, and there is no measurable difference between the offsets of the different recordings.
>> 
>> 
>> These are the values of one test (input/output, rounded to ms):
>> Suggested Latency: 0.010 / 0.010
>> ”Actual” Latency (PaStreamInfo): 0.059 / 0.020
>> Diff ADC/DAC: 0.035
>> ”Real-world”: 0.044
>> 
>> And another:
>> Suggested Latency: 0.040 / 0.040
>> ”Actual” Latency (PaStreamInfo): 0.233 / 0.061
>> Diff ADC/DAC: 0.110
>> ”Real-world”: 0.157
>> 
>> I’m certainly not an expert on these matters, but to me the values reported by PaStreamInfo looks weird – the input latency cannot possibly be 59 ms when the recorded ”echo” starts 44 ms into the file?! Furthermore, I would have expected some sort of match between the PaStreamInfo latency values and the ADC/DAC diff. Here, I can see no obvious relation between them.
>> 
>> The ADC/DAC diff seems to be closest to the real-world values, and in the first example, I could have just accepted the 9 ms diff for the unknown latency which lays outside of the knowledge of PortAudio. But in that case, it wouldn’t have increased so much in the second example, I would rather have expected a constant addition.
>> 
>> How is this supposed to be done? Is it even possible to have the system roundtrip latency automatically calculated? (But even if the answer is no, the values reported by PaStreamInfo still don’t make any sense IMO!)
>> 
>> Best regards
>> Erik
>> 
>> PS. I’m on CoreAudio, Mac OS X 10.10
>> 
>> 
>> _______________________________________________
>> Portaudio mailing list
>> Portaudio at lists.columbia.edu <mailto:Portaudio at lists.columbia.edu>
>> https://lists.columbia.edu/mailman/listinfo/portaudio <https://lists.columbia.edu/mailman/listinfo/portaudio>_______________________________________________
> Portaudio mailing list
> Portaudio at lists.columbia.edu <mailto:Portaudio at lists.columbia.edu>
> https://lists.columbia.edu/mailman/listinfo/portaudio <https://lists.columbia.edu/mailman/listinfo/portaudio>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.columbia.edu/pipermail/portaudio/attachments/20151208/06ab169b/attachment-0001.html>


More information about the Portaudio mailing list