Changes between Initial Version and Version 1 of MeasuringSoundLatency


Ignore:
Timestamp:
Jul 28, 2008 11:14:07 AM (11 years ago)
Author:
bennylp
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MeasuringSoundLatency

    v1 v1  
     1= Measuring Sound Latency = 
     2 
     3This article describes how to measure both sound device latency and overall (end-to-end) latency of [http://www.pjsip.org/pjsua.htm pjsua]. The objective of the test is to measure the latency introduced by both the sound device and the [http://www.pjsip.org/pjmedia/docs/html/index.htm pjmedia] framework. 
     4 
     5== Requirements == 
     6 
     7You will need: 
     8 * [http://www.pjsip.org/pjsua.htm pjsua] 
     9 * a computer with microphone and loudspeaker (not headset) 
     10 * {{{tock8.wav}}} WAV file (see the attachment on the bottom of this page) 
     11 * a WAV waveform display/analyzer to visually see the latency (such as Cool Edit on Windows) 
     12 * or {{{latency.c}}} file (see the attachment on the bottom of this page) if you don't have WAV waveform analyzer program. 
     13 
     14== Setup == 
     15 
     16 * You MUST make sure that the loudspeaker level is set high enough so that the output is fed-back to the microphone (i.e. we deliberately want to capture the audio echo) 
     17 * Build pjsua and the latency.c 
     18 
     19 
     20== Measuring Sound Device Latency == 
     21 
     22This test will measure the total latency introduced by: 
     23 * microphone and speaker device buffering (both in application layer, driver layer, and hardware itself) 
     24 * conference bridge buffering 
     25 
     26Test method: 
     27 * play a special WAV file to the speaker device, and simultaneously record WAV file 
     28 * as the audio is played in the speaker, capture the signal in the microphone (i.e. similar to how sound echo is captured) 
     29 * record the microphone capture to WAV file. 
     30 
     31By looking in the recorded WAV file we should be able to know the sound device latency by measuring the interval between the recording of original signal and recording of the echo signal. 
     32 
     33 
     34=== Running the Test === 
     35 
     36Run pjsua: 
     37 
     38 {{{ 
     39 pjsua --no-tones --ec-tail 0 --rec-file rec1.wav --clock-rate 8000 --snd-clock-rate 8000 --play-file tock8.wav 
     40 }}} 
     41 
     42Run this script all at once (i.e. copy these and paste it to pjsua): 
     43 
     44 {{{ 
     45cc 0 0 
     46cc 1 0 
     47cc 1 2 
     48cc 0 2 
     49sleep 10000 
     50cd 0 0 
     51cd 1 0 
     52cd 1 2 
     53cd 0 2 
     54q 
     55 
     56 }}} 
     57 
     58The command above will play the tock8.wav file to the speaker over and over for 10 seconds, while at the same time both the WAV file and the microphone signal will be recorded to {{{rec1.wav}}} file.  
     59 
     60=== Analyzing the result with WAV analyzer === 
     61 
     62Here's what the recorded signal ({{{rec1.wav}}}) looks like in my WAV analyzer: 
     63 
     64 
     65The highlighted area in above picture shows one recording of both original signal and the echo. 
     66 
     67If we zoom-in the highlighted area, it will look like this: 
     68 
     69And to find out the latency, just measure the interval between original signal and echoed signal: 
     70 
     71In this test, I found out that the latency is approximately 171 milliseconds. 
     72 
     73 
     74=== Analyzing the result with latency analyzer === 
     75 
     76If you don't have WAV waveform analyzer, you can measure the latency using {{{latency.c}}} application. 
     77 
     78 {{{ 
     79 C:\> latency.exe rec1.wav 
     80Latency average = 197 
     81Latency minimum = 173 
     82Latency maximum = 213 
     83Number of data  = 9 
     84 }}} 
     85 
     86