Simultaneity in the AirPlay Universe

Most Apple products support the streaming of audio (and some even video) data through the network to AirPlay enabled devices like Apple TV, AirPort Express or third vendor products. Apple advertises the AirPlay technology with:

[...], you can stream your tunes to more than one room simultaneously, [...]. AirPlay works over Wi-Fi or an Ethernet connection, or a combination of both.

But how simultan can these devices stream under real world conditions? I tried to address this issue with two 2nd generation Apple TVs and an iMac Streaming through Wi-Fi and Gigabit Ethernet. It proved to be a difficult task to measure this precisely!

The 2nd generation Apple TV has only an optical TOSLINK audio output and a HDMI output, there is no way to get the analog audio signal directly. My first idea to compare the S/PDIF data streams was difficult. It was required to convert the data stream to electrical signals to be able to analyse them with my oscilloscope. As the fiber optic receiving modules TORX* from Toshiba are dependent from the power supply the signal wasn't 100% identical. I also discarded my second idea to use simple S/PDIF-to-RCA connectors. There are either cheap and of questionable quality or rare and expensive and could also have an impact on the measurement. So I decided another way to go:

Screenshot of RAW S/PDIF data

Screenshot of RAW S/PDIF data

I connected the iMac and the 2 Apple TVs using optical TOSLINK cables to 3 TORX177PL. They were powered with 5V using a programmable power supply. The output signal was grabbed with my Agilent DSO-X 3014A which saved the data to an USB stick in RAW Format. Then the data was copied to my iMac and post-processed using a self-written program which extracts the S/PDIF stream from the RAW data file, decodes it and writes the actual audio data to an output file. As the oscilloscope recorded the signal of all 3 sources at the same time it is possible to make statements about the relative times.

I did all the measurements using a 10 minute 16 bit uncompressed AIFF file with a 50 Hz tone using a 48000 kHZ sample rate to have the same conditions for all measurements. The 50 Hz tone has a periodicity of 20 ms, which was the maximum time frame I was able to measure at one measurement. If I would have chosen larger time frames, the time resolution wouldn't be enough to decode the S/PDIF signal without errors. As I would not be able to measure time delays of more than 20 ms with that method I did several test measurements with music audio data and the delay was always below 20 ms.

The following picture shows an example measurement after decoding the S/PDIF data stream. The red signal comes from the optical output of the iMac, the green signal from an Apple TV connected by WiFi and the blue signal from an Apple TV connected by Ethernet.

Example measurement

As we chose an exact 50 Hz sine tone it was easy to fit the time differences with gnuplot. We also fitted the time difference in reference to the iMac. In this example the green curve from the WiFi connected Apple TV has a delay of 0.42 ms and the blue curve from the Ethernet connected Apple TV has a delay of 1.39 ms.

We did a total of 30 measurements: 10 with both Apple TV connected to WLAN, 10 with one Apple TV connected to WLAN and the other one connected to LAN and 10 with both Apple TV connected to LAN. The following figure shows a summary of the time delays measured. After 10 measurements, when the connection was changed, both Apple TVs were restarted a reselected in iTunes as additional speakers. It's strange to see, that the devices connected to Ethernet have longer delays than those connected to WiFi.

Time delays

This cannot be seen that easily in music audio data as the next example shows. As both Apple TV devices output the data as a 48 kHZ S/PDIF stream whereas the iMac produces an 44.1 kHZ S/PDIF stream the signal is a little bit different, but in this example it's easy to see, that Apple TV connected to Ethernet is about 0.1 ms before the iMac whereas the Apple TV connected to WiFi is about 0.3 ms behind.

WiFi/Ethernet comparison

In summary it can be said, that the latency between the different sources is less than 2 ms which is in my opinion a rather good value compared to how easy this thing is to install. Just plug it in and it just works, independent from the connection over Ethernet of WiFi.

3 thoughts on “Simultaneity in the AirPlay Universe

  1. Really cool experiment. I've always wondered how in sync this stuff was. I have 4 x ATV + 4 x ATV2 + AP Express around my house. They all just work.

  2. Thanks for doing the homework for us. I was always wondering about this as I have an airport express and apple tv setup at home and I'm amazed at how I couldn't detect any form of latency in the audio output. Nice to see someone do the actual measuring up

Leave a Reply to Dexter Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.