Friday, November 25, 2011

Possibility for Airplay/AirTunes to Airport Express with Hi-Res Audio

I'm quite happy with my modified Airport Express currently since I can use my iPhone/iPad/iMac streaming audio files to Airport Express on demand.

However, the only drawback is: AE only supports 16-bit 44.1 kHz sampling rate.

Even though, I still can successfully play the 24-bit 96 kHz on my iTunes, and "airplays" onto AE, and AE will send the stream to my DAC via SPDIF. In this case, the DAC shows that the signal is a 16-bit / 44.1 kHz one.

This implies that there's a device along the path which did the down sampling from 24/96 to 16/44.1 for sure. But the question is: is the down-sampling done by iTunes or the AE itself?

I try to find the answer through the Internet, however there's no firm answer.

I decided to find the answer by myself, and I found this:

JustePort

Jon Lech Johansen has shown us a way to send an audio stream to the AE.
I then compile Jon's code on my desktop, and send the following two files in Apple lossless format by his JustePort to my AE.

Streaming-Test$ mono JustePort.exe Koln-16-44.m4a 10.100.1.6

JackStatus: connected

JackType: analog

^C
Streaming-Test$ 



Streaming-Test$ mono JustePort.exe Koln-24-96.m4a 10.100.1.6JackStatus: connected

JackType: analog
^C
Streaming-Test$
With the 16/44.1 file, the AE works well as usual, but with 24/96 one, AE couldn't successfully decode the audio stream, but is still passing the signal to my DAC, and it sounds just like a bunch of digital noise.
Through this test, I confirm that AE itself can only handle 16/44.1. If you are trying to send a 24/96 audio stream to it, it just can't recognize it, and is not able to decode the stream.
Obviously, for audio file above 16/44.1, the down-sampling takes place in iTunes and the audio stream gets converted into 16/44.1 before it leaving the iTunes.
Findings Now I have two findings through this simple test: 1. If I can make an Airplay streaming receiver similar to AE, however supporting higher sampling rate, then I will be able to play 24/96 audio files with it.
2. Down-sampling is done by iTunes for sure, hence, even if I can make an AE-like but is a 24/96 capable receiver, I also need to make sure that iTune will send an 24/96 audio stream to it without down-sampling.
iTunes with Airport Express The following is the RTSP ANNOUNCE message sent by iTunes
ANNOUNCE rtsp://10.0.1.101/3172942895 
RTSP/1.0
CSeq: 1
Content-Type: application/sdp
Content-Length: 567
User-Agent: iTunes/4.6 (Windows; N)
Client-Instance: 9FF35780A8BC8D2B
Apple-Challenge: 09KF45soMYmvj6dpsUGiIg

v=0
o=iTunes 3172942895 0 IN IP4 10.0.1.101
s=iTunesc=IN IP4 10.0.1.103
t=0 0
m=audio 0 RTP/AVP 96
a=rtpmap:96 AppleLossless
a=fmtp:96 4096 0 16 40 10 14 2 255 0 0 44100
a=rsaaeskey:5QYIqmdZGTONY5SHjEJrqAhaa0W9wzDC5i6q221mdGZJ5ubO6Kg
yhC6U83wpY87TFdPRdfPQl2kVC7+Uefmx1bXdIUo07ZcJsqMbgtje4w2JQw0b
Uw2BlzNPmVGQOxfdpGc3LXZzNE0jI1D4conUEiW6rrzikXBhk7Y/i2naw13ayy
xaSwtkiJ0ltBQGYGErbV2tx43QSNj7O0JIG9GrF2GZZ6/UHo4VH+ZXgQ4NZvP/
QXPCsLutZsvusFDzIEq7TN1fveINOiwrzlN+bckEixvhXlvoQTWE2tjbmQYhMvO
FIly5gNbZiXi0l5AdolX4jDC2vndFHqWDks/3sPikNga=aesiv:zcZmAZtqh7uGcEwPXk0QeA

RTSP/1.0 200 OK
CSeq: 1
Apple-Response: u+msU8Cc7KBrVPjI/Ir8fOL8+C5D3Jsw1+acaW3MNTndrTQAeb/a
5m10UVBX6wb/DYQGY+b28ksSwBjN0nFOk4Y2cODEf83FAh7B
mkLpmpkpplp7zVXQ+Z9DcB6gC60ZsS3t98aoR7tSzVLKZNgi2X2sC+vGsz
utQxX03HK008VjcdngHv3g1p2knoETd07T6eVfZCmPqp6Ga7Dj8VIIj/GEP3
AjjDx3lJnQBXUDmxM484YXLXZjWFXCiY8GJt6whjf7/2c3rIoT3Z7PQpEvPmM
1MXU9cv4NL59Y/q0OAVQ38foOz7eGAhfvjOsCnHU25aik7/7ToIYt1tyVtap/kA
Audio-Jack-Status: connected; type=analog

We can see that iTunes announce the parameters in a=fmtp: section, and possibly specifying the followings:

Codec = 96 (Apple lossless)
Frames-per-packet = 4096 (ALAC default setting)
Compatible Version = 0 (must be 0)
Sample-Size = 16 (so called bit-depth, max = 32)
pb = 40 (currently unused parameter, should be set to 40)
kb = 10 (currently unused parameter, should be set to 10)
mb = 14 (currently unused parameter, should be set to 14)
Number of Channels = 2 (i.e. stereo)
Max Run = 255 (currently unused parameter, should be set to 255)
Max Frame Bytes = 0 (The max size of an ALAC packet within the encoded stream, 0 = unknown)
Average Bit Rate = 0 (Average Bit Rate in bps, 0 = unknown)
Sampling-Rate = 44100

Hint: the above info were discovered from ALAC code.

A Simple Test

As we can see that the Sample Size (16 bits) and Sampling Rate (44100 Hz) of the audio stream is ANNOUNCED in the RSTP ANNOUNCE message by the Session Description Protocol (SDP), I'm wondering what will happen if I set those parameters to 24/96k instead?

I then modify the JustePort source codes, and set those values to 24/96k, recompile and play a 24/96k ALAC file. At first, AE received the stream, but couldn't decode it (of course), and produced hiss sound.  And then about half a second, the JustePort reports error, then stream is then terminated. After that, I was no longer able to send any further audio stream to the AE, since it just refused for any connection. (I guess AE was crashed at this stage, even it still responded to PING.)

I also played a 16/44.1k file with the modified 24/96k JustePort, although the AE cannot successfully decode the stream, however it didn't crash. After that, I can still play a 16/44.1k file with the normal version of JustePort.

To me, this small test proved a few things:

1. SDP parameters determine how does the AE decode the audio stream. Even if 24/96k is supported on  AE, you might need to change the SDP parameters as well.
2. SDP parameters must match the ALAC format.

Conclusion for iTunes+AE 

1. iTunes down-sampling the ALAC file to 16/44.1 if it is originally at higher sampling rate.
2. iTunes encapsulates and sends the ALAC stream to AE directly.
3. Decoding is done on the AE, and AE only supports 16/44.1.

iTunes with AppleTV (2nd Gen)

So, how about the Apple TV?

It is known that Apple TV will up/down-sample everything to 16/48k, but my questions on mind are:

1. Where does the up/down-sampling taking place? Done by iTunes? Or the AppleTV itself?

2. If the up/down-sampling is done by iTunes, I should be able to see the SDP parameters are set to the same with the audio source file.

3. If the up/down-sampling is done by AppleTV, then at what sampling-size/rate does the iTunes send?

Recalling that SDP parameters should match the audio file, I did the following test:


  • Play a 16/44.1k and a 24/96k file with iTune and sending to Apple TV
  • Perform a packet capture with Wireshark


The followings are the captured ROAP/RSTP ANNOUNCE packets for 16/44.1k and 24/96k respectively:


  • 16/44.1k file playback:

No.     Time        Source                Destination           Protocol Length Info
   2789 5.633568    fe80::c62c:3ff:fe12:cdc0 fe80::5a55:caff:fe4e:bd6b TCP      732    54702 > 49152 [PSH, ACK] Seq=720 Ack=400 Win=65688 Len=646 TSval=778938126 TSecr=839386389


Frame 2789: 732 bytes on wire (5856 bits), 732 bytes captured (5856 bits)
Ethernet II, Src: Apple_12:cd:c0 (c4:2c:03:12:cd:c0), Dst: Apple_4e:bd:6b (58:55:ca:4e:bd:6b)
Internet Protocol Version 6, Src: fe80::c62c:3ff:fe12:cdc0 (fe80::c62c:3ff:fe12:cdc0), Dst: fe80::5a55:caff:fe4e:bd6b (fe80::5a55:caff:fe4e:bd6b)
Transmission Control Protocol, Src Port: 54702 (54702), Dst Port: 49152 (49152), Seq: 720, Ack: 400, Len: 646
    Source port: 54702 (54702)
    Destination port: 49152 (49152)
    [Stream index: 41]
    Sequence number: 720    (relative sequence number)
    [Next sequence number: 1366    (relative sequence number)]
    Acknowledgement number: 400    (relative ack number)
    Header length: 32 bytes
    Flags: 0x18 (PSH, ACK)
    Window size value: 32844
    [Calculated window size: 65688]
    [Window size scaling factor: 2]
    Checksum: 0x100c [validation disabled]
        [Good Checksum: False]
        [Bad Checksum: False]
    Options: (12 bytes)
        No-Operation (NOP)
        No-Operation (NOP)
        Timestamps: TSval 778938126, TSecr 839386389
            Kind: Timestamp (8)
            Length: 10
            Timestamp value: 778938126
            Timestamp echo reply: 839386389
    [SEQ/ACK analysis]
        [Bytes in flight: 646]
Data (646 bytes)

0000  41 4e 4e 4f 55 4e 43 45 20 72 74 73 70 3a 2f 2f   ANNOUNCE rtsp://
0010  66 65 38 30 3a 3a 63 36 32 63 3a 33 66 66 3a 66   fe80::c62c:3ff:f
0020  65 31 32 3a 63 64 63 30 2f 33 34 30 35 31 31 35   e12:cdc0/3405115
0030  33 38 38 20 52 54 53 50 2f 31 2e 30 0d 0a 43 53   388 RTSP/1.0..CS
0040  65 71 3a 20 33 0d 0a 43 6f 6e 74 65 6e 74 2d 54   eq: 3..Content-T
0050  79 70 65 3a 20 61 70 70 6c 69 63 61 74 69 6f 6e   ype: application
0060  2f 73 64 70 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65   /sdp..Content-Le
0070  6e 67 74 68 3a 20 33 34 38 0d 0a 55 73 65 72 2d   ngth: 348..User-
0080  41 67 65 6e 74 3a 20 69 54 75 6e 65 73 2f 31 30   Agent: iTunes/10
0090  2e 35 2e 31 20 28 4d 61 63 69 6e 74 6f 73 68 3b   .5.1 (Macintosh;
00a0  20 49 6e 74 65 6c 20 4d 61 63 20 4f 53 20 58 20    Intel Mac OS X 
00b0  31 30 2e 36 2e 38 29 20 41 70 70 6c 65 57 65 62   10.6.8) AppleWeb
00c0  4b 69 74 2f 35 33 34 2e 35 31 2e 32 32 0d 0a 43   Kit/534.51.22..C
00d0  6c 69 65 6e 74 2d 49 6e 73 74 61 6e 63 65 3a 20   lient-Instance: 
00e0  42 38 41 45 45 41 45 42 45 35 39 37 44 42 44 37   B8AEEAEBE597DBD7
00f0  0d 0a 44 41 43 50 2d 49 44 3a 20 42 38 41 45 45   ..DACP-ID: B8AEE
0100  41 45 42 45 35 39 37 44 42 44 37 0d 0a 41 63 74   AEBE597DBD7..Act
0110  69 76 65 2d 52 65 6d 6f 74 65 3a 20 34 31 38 38   ive-Remote: 4188
0120  32 32 30 30 38 30 0d 0a 0d 0a 76 3d 30 0d 0a 6f   220080....v=0..o
0130  3d 69 54 75 6e 65 73 20 33 34 30 35 31 31 35 33   =iTunes 34051153
0140  38 38 20 30 20 49 4e 20 49 50 34 20 66 65 38 30   88 0 IN IP4 fe80
0150  3a 3a 63 36 32 63 3a 33 66 66 3a 66 65 31 32 3a   ::c62c:3ff:fe12:
0160  63 64 63 30 0d 0a 73 3d 69 54 75 6e 65 73 0d 0a   cdc0..s=iTunes..
0170  63 3d 49 4e 20 49 50 34 20 66 65 38 30 3a 3a 35   c=IN IP4 fe80::5
0180  61 35 35 3a 63 61 66 66 3a 66 65 34 65 3a 62 64   a55:caff:fe4e:bd
0190  36 62 0d 0a 74 3d 30 20 30 0d 0a 6d 3d 61 75 64   6b..t=0 0..m=aud
01a0  69 6f 20 30 20 52 54 50 2f 41 56 50 20 39 36 0d   io 0 RTP/AVP 96.
01b0  0a 61 3d 72 74 70 6d 61 70 3a 39 36 20 41 70 70   .a=rtpmap:96 App
01c0  6c 65 4c 6f 73 73 6c 65 73 73 0d 0a 61 3d 66 6d   leLossless..a=fm
01d0  74 70 3a 39 36 20 33 35 32 20 30 20 31 36 20 34   tp:96 352 0 16 4
01e0  30 20 31 30 20 31 34 20 32 20 32 35 35 20 30 20   0 10 14 2 255 0 
01f0  30 20 34 34 31 30 30 0d 0a 61 3d 66 70 61 65 73   0 44100..a=fpaes
0200  6b 65 79 3a 52 6c 42 4d 57 51 45 43 41 51 41 41   key:RlBMWQECAQAA
0210  41 41 41 38 41 41 41 41 41 46 6e 4d 53 77 79 48   AAA8AAAAAFnMSwyH
0220  2b 50 47 41 48 4d 59 6f 56 59 50 31 6b 7a 55 41   +PGAHMYoVYP1kzUA
0230  41 41 41 51 31 78 58 4c 56 72 57 55 36 4c 76 77   AAAQ1xXLVrWU6Lvw
0240  36 30 37 62 78 64 73 52 72 61 48 5a 52 50 54 62   607bxdsRraHZRPTb
0250  33 51 35 2f 50 34 65 63 48 7a 7a 43 32 75 68 39   3Q5/P4ecHzzC2uh9
0260  6e 71 42 79 0d 0a 61 3d 61 65 73 69 76 3a 47 79   nqBy..a=aesiv:Gy
0270  62 52 45 61 42 6a 39 71 6f 57 70 71 46 6c 46 55   bREaBj9qoWpqFlFU
0280  48 66 55 41 0d 0a                                 HfUA..
    Data: 414e4e4f554e434520727473703a2f2f666538303a3a6336...
    [Length: 646]

24/96k file playback:
No.     Time        Source                Destination           Protocol Length Info
   3635 7.948851    fe80::c62c:3ff:fe12:cdc0 fe80::5a55:caff:fe4e:bd6b TCP      732    56361 > 49152 [PSH, ACK] Seq=720 Ack=400 Win=65688 Len=646 TSval=778943908 TSecr=839964791

Frame 3635: 732 bytes on wire (5856 bits), 732 bytes captured (5856 bits)
    Arrival Time: Nov 26, 2011 01:32:47.458693000 CST
    Epoch Time: 1322242367.458693000 seconds
    [Time delta from previous captured frame: 0.000465000 seconds]
    [Time delta from previous displayed frame: 0.000465000 seconds]
    [Time since reference or first frame: 7.948851000 seconds]
    Frame Number: 3635
    Frame Length: 732 bytes (5856 bits)
    Capture Length: 732 bytes (5856 bits)
    [Frame is marked: False]
    [Frame is ignored: False]
    [Protocols in frame: eth:ipv6:tcp:data]
    [Coloring Rule Name: TCP]
    [Coloring Rule String: tcp]
Ethernet II, Src: Apple_12:cd:c0 (c4:2c:03:12:cd:c0), Dst: Apple_4e:bd:6b (58:55:ca:4e:bd:6b)
    Destination: Apple_4e:bd:6b (58:55:ca:4e:bd:6b)
        Address: Apple_4e:bd:6b (58:55:ca:4e:bd:6b)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
    Source: Apple_12:cd:c0 (c4:2c:03:12:cd:c0)
        Address: Apple_12:cd:c0 (c4:2c:03:12:cd:c0)
        .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
        .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
    Type: IPv6 (0x86dd)
Internet Protocol Version 6, Src: fe80::c62c:3ff:fe12:cdc0 (fe80::c62c:3ff:fe12:cdc0), Dst: fe80::5a55:caff:fe4e:bd6b (fe80::5a55:caff:fe4e:bd6b)
    0110 .... = Version: 6
        [0110 .... = This field makes the filter "ip.version == 6" possible: 6]
    .... 0000 0000 .... .... .... .... .... = Traffic class: 0x00000000
        .... 0000 00.. .... .... .... .... .... = Differentiated Services Field: Default (0x00000000)
        .... .... ..0. .... .... .... .... .... = ECN-Capable Transport (ECT): Not set
        .... .... ...0 .... .... .... .... .... = ECN-CE: Not set
    .... .... .... 0000 0000 0000 0000 0000 = Flowlabel: 0x00000000
    Payload length: 678
    Next header: TCP (0x06)
    Hop limit: 2
    Source: fe80::c62c:3ff:fe12:cdc0 (fe80::c62c:3ff:fe12:cdc0)
    [Source SA MAC: Apple_12:cd:c0 (c4:2c:03:12:cd:c0)]
    Destination: fe80::5a55:caff:fe4e:bd6b (fe80::5a55:caff:fe4e:bd6b)
    [Destination SA MAC: Apple_4e:bd:6b (58:55:ca:4e:bd:6b)]
Transmission Control Protocol, Src Port: 56361 (56361), Dst Port: 49152 (49152), Seq: 720, Ack: 400, Len: 646
    Source port: 56361 (56361)
    Destination port: 49152 (49152)
    [Stream index: 27]
    Sequence number: 720    (relative sequence number)
    [Next sequence number: 1366    (relative sequence number)]
    Acknowledgement number: 400    (relative ack number)
    Header length: 32 bytes
    Flags: 0x18 (PSH, ACK)
        000. .... .... = Reserved: Not set
        ...0 .... .... = Nonce: Not set
        .... 0... .... = Congestion Window Reduced (CWR): Not set
        .... .0.. .... = ECN-Echo: Not set
        .... ..0. .... = Urgent: Not set
        .... ...1 .... = Acknowledgement: Set
        .... .... 1... = Push: Set
        .... .... .0.. = Reset: Not set
        .... .... ..0. = Syn: Not set
        .... .... ...0 = Fin: Not set
    Window size value: 32844
    [Calculated window size: 65688]
    [Window size scaling factor: 2]
    Checksum: 0xc7a9 [validation disabled]
        [Good Checksum: False]
        [Bad Checksum: False]
    Options: (12 bytes)
        No-Operation (NOP)
        No-Operation (NOP)
        Timestamps: TSval 778943908, TSecr 839964791
            Kind: Timestamp (8)
            Length: 10
            Timestamp value: 778943908
            Timestamp echo reply: 839964791
    [SEQ/ACK analysis]
        [Bytes in flight: 646]
Data (646 bytes)

0000  41 4e 4e 4f 55 4e 43 45 20 72 74 73 70 3a 2f 2f   ANNOUNCE rtsp://
0010  66 65 38 30 3a 3a 63 36 32 63 3a 33 66 66 3a 66   fe80::c62c:3ff:f
0020  65 31 32 3a 63 64 63 30 2f 33 34 30 35 31 31 35   e12:cdc0/3405115
0030  39 36 37 20 52 54 53 50 2f 31 2e 30 0d 0a 43 53   967 RTSP/1.0..CS
0040  65 71 3a 20 33 0d 0a 43 6f 6e 74 65 6e 74 2d 54   eq: 3..Content-T
0050  79 70 65 3a 20 61 70 70 6c 69 63 61 74 69 6f 6e   ype: application
0060  2f 73 64 70 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65   /sdp..Content-Le
0070  6e 67 74 68 3a 20 33 34 38 0d 0a 55 73 65 72 2d   ngth: 348..User-
0080  41 67 65 6e 74 3a 20 69 54 75 6e 65 73 2f 31 30   Agent: iTunes/10
0090  2e 35 2e 31 20 28 4d 61 63 69 6e 74 6f 73 68 3b   .5.1 (Macintosh;
00a0  20 49 6e 74 65 6c 20 4d 61 63 20 4f 53 20 58 20    Intel Mac OS X 
00b0  31 30 2e 36 2e 38 29 20 41 70 70 6c 65 57 65 62   10.6.8) AppleWeb
00c0  4b 69 74 2f 35 33 34 2e 35 31 2e 32 32 0d 0a 43   Kit/534.51.22..C
00d0  6c 69 65 6e 74 2d 49 6e 73 74 61 6e 63 65 3a 20   lient-Instance: 
00e0  42 38 41 45 45 41 45 42 45 35 39 37 44 42 44 37   B8AEEAEBE597DBD7
00f0  0d 0a 44 41 43 50 2d 49 44 3a 20 42 38 41 45 45   ..DACP-ID: B8AEE
0100  41 45 42 45 35 39 37 44 42 44 37 0d 0a 41 63 74   AEBE597DBD7..Act
0110  69 76 65 2d 52 65 6d 6f 74 65 3a 20 34 31 38 38   ive-Remote: 4188
0120  32 32 30 30 38 30 0d 0a 0d 0a 76 3d 30 0d 0a 6f   220080....v=0..o
0130  3d 69 54 75 6e 65 73 20 33 34 30 35 31 31 35 39   =iTunes 34051159
0140  36 37 20 30 20 49 4e 20 49 50 34 20 66 65 38 30   67 0 IN IP4 fe80
0150  3a 3a 63 36 32 63 3a 33 66 66 3a 66 65 31 32 3a   ::c62c:3ff:fe12:
0160  63 64 63 30 0d 0a 73 3d 69 54 75 6e 65 73 0d 0a   cdc0..s=iTunes..
0170  63 3d 49 4e 20 49 50 34 20 66 65 38 30 3a 3a 35   c=IN IP4 fe80::5
0180  61 35 35 3a 63 61 66 66 3a 66 65 34 65 3a 62 64   a55:caff:fe4e:bd
0190  36 62 0d 0a 74 3d 30 20 30 0d 0a 6d 3d 61 75 64   6b..t=0 0..m=aud
01a0  69 6f 20 30 20 52 54 50 2f 41 56 50 20 39 36 0d   io 0 RTP/AVP 96.
01b0  0a 61 3d 72 74 70 6d 61 70 3a 39 36 20 41 70 70   .a=rtpmap:96 App
01c0  6c 65 4c 6f 73 73 6c 65 73 73 0d 0a 61 3d 66 6d   leLossless..a=fm
01d0  74 70 3a 39 36 20 33 35 32 20 30 20 31 36 20 34   tp:96 352 0 16 4
01e0  30 20 31 30 20 31 34 20 32 20 32 35 35 20 30 20   0 10 14 2 255 0 
01f0  30 20 34 34 31 30 30 0d 0a 61 3d 66 70 61 65 73   0 44100..a=fpaes
0200  6b 65 79 3a 52 6c 42 4d 57 51 45 43 41 51 41 41   key:RlBMWQECAQAA
0210  41 41 41 38 41 41 41 41 41 46 4a 70 46 65 37 63   AAA8AAAAAFJpFe7c
0220  6d 6c 6f 57 61 59 6b 79 70 34 47 5a 4d 39 67 41   mloWaYkyp4GZM9gA
0230  41 41 41 51 63 59 4b 68 73 64 77 6e 30 72 68 50   AAAQcYKhsdwn0rhP
0240  7a 36 68 34 6c 54 50 46 63 64 73 47 38 6d 79 47   z6h4lTPFcdsG8myG
0250  6a 74 65 52 53 55 72 70 52 79 78 32 73 79 5a 71   jteRSUrpRyx2syZq
0260  4f 4b 7a 36 0d 0a 61 3d 61 65 73 69 76 3a 72 39   OKz6..a=aesiv:r9
0270  54 6a 4b 6a 46 73 37 42 34 57 44 70 41 68 4f 59   TjKjFs7B4WDpAhOY
0280  4b 73 36 67 0d 0a                                 Ks6g..
    Data: 414e4e4f554e434520727473703a2f2f666538303a3a6336...
    [Length: 646]

Did you see that?
16/44.1k:

a=fmtp:96 352 0 16 40 10 14 2 255 0 0 44100

24/96k:

a=fmtp:96 352 0 16 40 10 14 2 255 0 0 44100

The parameters are exactly the same at 16-bits / 44100 Hz !!

Now we have revealed Apple's big secrets:

1. On Apple TV, up/down sampling is done on the Apple TV itself. (Not a big deal)

2. iTunes ALWAYS down-sampling the audio file to 16/44.1k, no matter the remote end is an AE or Apple TV. In other words, iTune was hard-coded to down-sampling to 16/44.1k while using the AirTunes ................ (This sucks!!)

3. The worst case for playing audio via AirPlay/AirTunes is: playing a Hi-Res file to an Apple TV!! Since the audio file is firstly down-sampled by iTunes and then up-sampled by Apple TV.

Conclusion



If we take a little consideration with the above information, it is not hard to understand why Apple doesn't want to support Hi-Res audio file playback through AirTunes/AirPlay.

To support the Hi-Res audio, they need to :

1. Modify the iTunes codes (so that the audio stream can be sent as it is without down-sampling)
2. Modify the AE/AppleTV firmware to accept the Hi-Res audio stream and decode it correctly.

This is not a trivial change for Apple from development perspective.

Even if I can make a Hi-Res capable AE-like device, I'll need to find an alternative solution for iTunes to get the native Hi-Res support.





49 comments:

  1. Per this article, http://www.computeraudiophile.com/content/New-Apple-TV-NOT-bit-perfect

    Does the volume setting in iTunes have an effect on the downsampling?

    ReplyDelete
  2. To Anonymous:

    The method in the AirTunes/AirPlay for adjusting volume is similar to the followings:

    1. Volume value is transmitted as an parameter in the RTSP/RAOP. The value is valid in the range between 0 and -144, while 0 means full volume.
    We can presume the value as db.

    http://www.cocoadev.com/index.pl?RemoteAudioOutputProtocol

    2. When user adjusts the volume bar to another level, iTune will send out a SET_PARAMETER message to AE/ATV, request it to adjust the output volume to the level specified.

    So the problem is:

    Even we connect the AE/ATV to a DAC, and the signal in between is digital one. To make the adjustment of the volume possible, the DAC chip on the AE/ATV must perform some resampling to lower down the level in the PCM waveform. In other words, that won't be bit-perfect. It does not change the sampling rate (remains 44.1kHz), however it does change the "level" (sampling size), for ex. change a value for every sample in 16-bit (-32768 ~ 32767) . This is effectively resample the signal from 16-bit to, say 10-bit for example.

    Due to this reason, I always set my volume to the maximum, hoping that the resampling will not take place on AE/ATV. (I assume that it won't at the full volume theoretically, but I'm not yet able to confirm this.)

    BTW, I'll never use the "Sound Check" feature in iTunes, since it has similar effect in the digital signal on the iTunes side.

    ReplyDelete
  3. Very interesting experiment. I modified an AE to improve its sound quality and in doing that I saw that the Marvell processor is able to support 24bit 96K and the DAC in the AE is able to support 24bit 192K.
    So indeed from you experiment it seems that the firmware is limiting, unless there is another parameter to change.
    2 questions:
    How about sending 24bit 44.1K or 48K or 16bit 48K or 88K does this work?
    Is it possible to send uncompressed pcm (i.e not ALAC) does teh AE understand other codecs?

    ReplyDelete
  4. How did you modify your AE? Can you now use AirPlay for 24/96?

    ReplyDelete
  5. To Anonymous,

    It won't work, AE can only understand 16/44.1K ALAC encoding stream so far.

    To Zachary,

    I modified my AE with linear power supply, and convert the TOS Link signal to S/PDIF coaxial with a DSIX-like driving circuit to make sure the rise/fall time is minimum as possible and also suppress the noise as possible.

    ReplyDelete
  6. To Zachary,

    For your 2nd question, no, I'm not able to make the AE accepting the 24/96 steam at this moment. I was just trying to find out the fact for Airplay regarding the Hi-RES capability, and see how we can make the Hi-RES happen.

    IMHO, it is almost impossible to modify AE's original firmware to support the Hi-RES stream unless we have the source code from Apple. But it may be more possible to build a third party AE which can support Hi-RES stream and compatible with Airplay.

    ReplyDelete
  7. finally someone with answers. Thanks

    ReplyDelete
  8. I have heard (though haven’t been able to confirm) that iTunes uses the parameters in the Audio MIDI Setup application to convert all audio to the same bit depth and sample rate. Have you tried adjusting this to see if it has any effect on AirPlay streaming?

    Tweaking these settings certainly seems to affect audio playback through the built-in output. The app claims to support up to 32/96 playback, though defaults to 16/24 with a 25.5dB attenuation, which would presumably drastically reduce overall dynamic range.

    It would certainly be nice if there were a software solution to this issue and this seems like something that might be worth experimenting with.

    ReplyDelete
  9. Wow. Wonderful work! Thank you very much!!
    Now, does anyone know of low-cost hardware that will receive by WiFi flac 16/44, 24/96 or 24/192 files and pass data bit for bit by usb or sp/dif to a DAC?

    ReplyDelete
  10. To All:

    It seems that the DB system has an solution for their AE-based La Rosita to support Hi-Res.
    On the computer end, they wrote a plug-in, and redirect the iTunes output to the plugin software.
    Then, the plug-in will send the music stream to the La Rosita at the same sampling rate from the original file. For this part, I'm not surprise with it.

    The mystery is, DB system may need to modify the firmware of the AE, and I think Apple will not be happy with this. I'm not saying that modify the firmware is impossible, but it may take quite a lot of efforts to get it done, and they have to ensure that there is no bug.

    I don't really believe that they have modified the firmware, since doing so without Apple's support will be extremely difficult. The only thing the DB system can easily do is the hardware, so this may imply that there's a way to remove the 16/44.1 limitation on the AE through hardware approach......

    ReplyDelete
  11. Everyone I'm sorry I've had a glass of wine so won't get technical. But...how about High Res File - Audirvana Plus software - Airfoil - Airport Express - DAC
    I think that works.

    ReplyDelete
  12. Hello stranger30,

    No problem at all.
    The point is : Will AAE accept the Hi-RES ALAC stream ?
    I didn't find see any evidence telling us that AAE can accept ALAC stream at Hi-RES other than 16/44.1k.

    ReplyDelete
  13. Brilliant and definitive post, very well done.

    ReplyDelete
  14. Great post, thank you very much!

    Would it help to run Amarra along with (or instead of?) iTunes?

    My data / music stream right now is:

    HiRes files in iTunes on a MacBook > DAC (RME AD-I 2) > Classé CP-500.

    (I wondered if I should buy an ATV2, but this seems no good idea after reading this post.)

    Thanks a lot for a hint!

    Peter

    ReplyDelete
  15. Hi Peter,

    Amarra won't help, the point is that the AAE will only work with 16-bit/44.1kHz ALAC stream.
    Glad to know my experiment is helpful to you.

    ReplyDelete
  16. This comment has been removed by the author.

    ReplyDelete
  17. Hi, I don't have Airport Express. I use a regular wireless router*.

    So, is there a bottleneck in my chain**? Are my data deteriorated before they arrive at the preamp?

    Thanks a lot!


    *) http://www.belkin.com/IWCatProductPage.process?Product_Id=543388
    **) iTunes > DAC > Preamp

    ReplyDelete
    Replies
    1. Hi there,

      I guess you are connecting iTunes/Mac to your DAC via the optical digital audio output, is it correct?

      In this case, iTunes will output in PCM format instead of ALAC, and the bit-depth/sampling rate will be the same as the original file. It will NOT be limited with 16-bit/44.1kHz. The questions with this kind of setup are:

      1) The transmission : The optical digital output is based on TOSLINK, and "usually" the TOSLINK can support up to 24-bit/96kHz since sometimes it is not fast enough for 24-bit/192kHz.

      2) The digital receiver: The other problem you might need to pay attention is : the DAC itself has a digital receiver, and it has its own limitation. Some digital receivers can only 24//192k and some can do up to 24/192k, so you may want to check the spec of the DAC.

      3) The DAC chip: Even the digital receiver itself can support upto 24/192k, the DAC chip must be able to support upto 24/192k. Most recent DAC chip can support 24/192k without problem, but some earlier DAC chips, especially the Non-oversampling one, such as TDA-1543, it can only work with 16/44.1k.

      HTH.

      Delete
  18. I wonder if anything has changed with the most recent revision of the Apple TV (3). Has anyone tested it?

    ReplyDelete
    Replies
    1. Hi Grimloch,

      I don't have ATV3, but I guess it is quite the same as ATV2 from software perspective.

      Delete
  19. Hi Ytsejam,
    thank you very much for pointing this out. You're right with my connection: MacBook > Toslink > DAC. I have got an RME AD-I2
    http://www.rme-audio.de/en_products_adi_2.php
    that meets the necessary specs you mentioned. I am relieved. :-)
    Peter

    ReplyDelete
  20. I want to use airplay or something similar to stream audio (44.1/16 bit is fine )to an iphone/ipad and have the video camera use my streamed audio **instead** of the microphone input. Is this possible?

    Calvin

    ReplyDelete
  21. I read here: http://artistsupport.topspinmedia.com/entries/21851522-High-resolution-audio-in-iTunes that if you change the "Audio Midi Setup" and edit their Audio settings than you can listen to real 24bit 96Khz on ITune but I dont know if you can srteam it thru the Airport.
    What do you think?

    ReplyDelete
    Replies
    1. Hi there, the MIDI setup is for local output only, IMHO, it won't affect the AirPlay.

      Delete
  22. Has anyone tested the new iTunes 11 and Apple TV (3) to see if Apple has made any improvements?

    ReplyDelete
  23. Great post with superb details. Thanks for sharing. Gatwick Airport Parking

    ReplyDelete
  24. Thank you very much, Ytsejam. Very interesting information.

    ReplyDelete
  25. There is another issue here and that is wireless bandwidth. Even if Apple starts supporting Hi Res audio on Airport Express and Apple TV it is unlikely it will stream satisfactorily due to the larger file sizes. I have tried and I get jittery buffering issues even on 16bit 44.1Khz lossless let alone anything higher res. The only way to play hi-res files (even with a compatible network player such as Cambridge Audio NP30 or Squeezebox) is via a 100mb+ cable like Ethernet. To get around cabling issues from room to room I use mains socket ethernet adapters close to my network players.

    ReplyDelete
    Replies
    1. Hi Dominic,

      Great comment! The WiFi bandwidth shouldn't be a problem for hi-RES, how due to the nature of the WiFi shared bus and radio interferance, indeed WiFi is not stable enough for the Hi-RES. Actually in my own implementation, I always AirPlay (actually WirePlay) to AAE through an Ethernet cable instead of WiFi. Actually, My latest solution is using AirPlay to Cubieboard via Ethernet, and then output via USB to an DAC instead. And also, I tried Raspberry as the AirPlay+USB DAC solution before, however the USB driver on the Raspberry sucks, caused random packet loss on USB, that's the reason I moved to Cubieboard in the end.

      Thanks for sharing!

      Delete
  26. found this post informative one, airport express equips one with the modern features. Car parking Heathrow

    ReplyDelete
  27. quite informative post. the brand has lots of improvement. in the same way car parking at moderate and assure security basis is offered by airport parking gatwick

    ReplyDelete
  28. This comment has been removed by the author.

    ReplyDelete
  29. That is really informative . Airport express has allotted their customers with new aspects of airplay . similar to it the modern featured parking services are introduced to provide the travelers with secure and hassle free parking services at airports before departure . just before arrival register your car and enjoy the stress free trip. deal with gatwick meet and greet

    ReplyDelete
  30. Very nice article and thanks for posting the above.

    I know that Airplay re-samples everything to 16-bit, 44.1 kHz and transcodes to ALAC for transmission. And, I also know that the 2d/3d-gen Apple TVs have a fixed output of 16-bit, 48kHz.

    However, when using HomeShare (i.e. pull) versus Airplay to play audio from an iTunes-hosting Mac to an Apple TV 3, what happens to 16-bit, 48kHz Apple Lossless tracks?

    I am hoping that HomeShare playback doesn't re-sample these tracks, but who knows? I ask because I have a large collection of hi-res tracks that I've re-sampled to 16/48 (from 24/96, 24/192), using iZotope64, and wonder how ATV 3 and iTunes will handle playback of 16-bit, 48kHz Apple Lossless tracks.

    ReplyDelete
  31. Why use iTunes?
    Did you test with other software? VLC or Audirvana etc?

    I am now looking for a WiFi audio transport system, with spdif output and support for 24/96 coded music.
    So far nothing...

    ReplyDelete
    Replies
    1. Hi there,

      Because I store all my media files on iTunes, and play them to AAE by Remote App on iPad.

      There's always some other ways to play 24/96, even 24/192, but I don't want to sacrifice the convenience of use.

      Delete
  32. This comment has been removed by the author.

    ReplyDelete
  33. I'd like an individual's destination. It is really superior to look at anybody verbalize with the heart and soul and also readability on that topic area mandatory section are typically opportunely determined. hi rise camera

    ReplyDelete
  34. Thanks for the nice blog. It was very useful for me. I'm happy I found this blog. Thank you for sharing with us,I too always learn something new from your post html color codes

    ReplyDelete
  35. very interesting charts and data. I can understand your position well now.
    Foxsportsgo

    ReplyDelete
  36. Minyak bulus adalah konsentrat minyak yang berasal dari kura-kura atau penyu air tawar (bulus). Di Indonesia, minyak bulus didapatkan melauli proses pengolahan tradisional, yaitu dengan memanaskan lemak penyu dan bagian tubuh lainnya di bawah terik matahari sehingga menghasilkan minyak. Minyak bulus umumnya dijual dalam bentuk botolan kecil, meski juga ada beberapa produsen yang menawarkan minyak bulus dalam bentuk suplemen kapsul

    ReplyDelete
  37. This comment has been removed by the author.

    ReplyDelete
  38. Hi there! This post on AirPlay to Airport Express is super helpful, especially for travelers like me. I recently had a fantastic experience using services of Express Parking for "Meet & Greet Heathrow T3" and I must say, it made my journey much smoother. Combining the convenience of AirPlay with stress-free Express parking at Heathrow T3, it's a winning combination for any traveler. Thanks for sharing this valuable information! ✈️

    ReplyDelete