[Portaudio] Reported latency
ericzhang at gmail.com
ericzhang at gmail.com
Mon Dec 7 17:57:31 EST 2015
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) wrote:
(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
Suggested Latency: 0.040 / 0.040
”Actual” Latency (PaStreamInfo): 0.233 / 0.061
Diff ADC/DAC: 0.110
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!)
PS. I’m on CoreAudio, Mac OS X 10.10
Portaudio mailing list
Portaudio at lists.columbia.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Portaudio