# (How to) measure display and sound system latency



## Chester (Feb 19, 2007)

What you will need:
Coil of wire
Solar cell
ADC (sound card/input of some sort)
Adobe Audition/Audacity
Excel (helpful)
Video editing/creating software http://www.nchsoftware.com/videopad/ (its free)

I wanted to calculate the delay introduced by both my LCD screen and also my amplifier; currently, I am assuming that the sound output and the video card output have the same latency, I feel this is fairly safe to assume, however I do want to look into that a bit more someday.

Basically, what you do is use a solar cell to measure a 'white flash' that is displayed on the screen, and an inductor to 'see' a click playing through the speakers. This allows us to find the differences between when the click and flash play. Knowing the difference in time allows us to adjust the audio or video delay to make everything time coherent. This can also be used to investigate the rise and fall time of the image.

You will need to make an audio file with 'clicks', in it at specific time points, in audition. you can generate silence, then somewhere in there edit one sample to be -3db, you now have your impulse. The file I generated has 10 seconds of silence, then 10 impulses, 2 seconds apart.

Then go into your video editing software and create some black to white screen transitions. The VideoPad program makes this very easy, in the main screen there is an option to create a 'blank' screen, or a screen of any color you want. Insert your audio file into the video editing software, and time align the audio to the black/white transition. Export the video as a movie file with with a frame rate that is equal to the refresh rate of your screen.

One part I 'breezed over' was formatting the audio data, I used a FFT eq to cut anything over 100 hz on the solar panel input, and both channels were normalized so that events would be easily visible.

Once you have all that, the following images will help to show how you measure things:
Measurement tools









Analog to Digital Converter I used, I checked that the channels are all perfectly time coherent. Tascam US-1800









Measuring the screen with a solar cell.









Inductor on speaker wire.









This is showing the rise time of an LED Flashlight which turns on effectively 'instantaneously', I used this to see how fast I can measure, based on this test, I figure I can resolve light intensity relative to time within 0.03125 ms









This shows an impulse measured off of the speaker wire using the inductor









This shows all 8 of my measurements, the screen was measured by changing a video from black to white, to black etc. every second @60fps, every 2 seconds there is a 'click' (impulse) which plays through the sound system.









Notice the markers, there are 3 per 'event', the first is 'the delay of the amplifier+dsp' before the impulse, which is when the computer is actually outputting the signal, the second is at the base of the pixel rise, the third is at the peak of the pixel rise.









Here is an individual event closer up.









Here are my calculations for the display latency, notice the StDev is ~1ms









This may be helpful visualizing the 'chain' of delays









So, what was my final answer? 9.71 ms of delay necessary for the audio 

NOTE: 9.71 ms is not much delay, for video at 60 fps, each frame is 16.7 ms long, remember, due to my crossover, I have 20 ms of delay added to the audio chain, and there is also delay introduced by from the sound traveling to my head. If I were using headphones, I would basically be dealing with 40 ms of delay (~2.4 frames @60 fps) which would be a bit more noticeable.


----------



## wgmontgomery (Jun 9, 2011)

Very interesting. Did I read this correctly? You measured the electrical signal from the amp _before_ it reached the speaker? I was thinking about the latency introduced by the difference in the speed of light and speed of sound, but if I follow what you did, this wouldn't be part of the equation.

I'll have to read this again after a cup of coffee. :yawn: Very interesting stuff! :T


----------



## wgmontgomery (Jun 9, 2011)

I looked at another graph that's posted and the speed of sound IS part of the total delay. :hail:

BTW-my reference to "a cup of coffee" in the post above was _not_ to indicate that I was bored; I meant that I needed to wake-up a bit.


----------



## Chester (Feb 19, 2007)

Yes, I have a cad model of the room/setup which I use to figure out the delay due to distance, just divide by the speed of sound and you have your delay  - my approach was to find the delay of each 'piece of the chain' so to speak which is why I measured the impulse off of the amplifier. Measuring directly off the amp gave me a sharper/cleaner impulse to reference off of also, which was another factor - I probably could have placed a mic at the listening position and achieved satisfactory results but I tend to over-engineer problems!

I could use a grill sparker (flash and bang), a tape measure (set distance), and a mic to figure out the speed of sound in air at my location too... just a thought 

I am currently in the process of doing a mic calibration with the grill sparker I referred to - we shall see how that works out, made some measurements last night!

The largest 'factor of uncertainty' I found when working on the speaker/display latency measurements was when to consider the pixel to be 'on' and when to consider it 'off', from what I know about human vision we do not see 'linearly' so my thinking was that i probably could use a 50% intensity value to indicate a changed pixel (where it would be outputting enough light to effectively be 'on') however I think that taking the average of the on/off times should get me pretty close. I am excited to have found a CHEAP (solar cell was ~$5) method to measure LCD pixel response times and performance, that will come in handy in the future.

Something else I forgot to mention: technically, the screen measurements should have been square waves; the ADC was applying DC offset to compensate for the voltage generated. I am unsure how the application of DC offset affected where the peaks of the screen measurements were; when 'testing' the panel with the LED flashlight, the voltage change was over a period of ~3 samples (effectively instantaneous) and there was basically no time for DC offset to affect things, with the screen measurement, it is pretty obvious that the DC offset was being applied as the voltage was increasing - whether or not this shifted the peaks/valleys a bit I do not know - if anyone has insight into this please help me out!


----------

