Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Problem: AirPay 1/2 doesn't seem to outputting lossless
#11
(07-31-2023, 10:25 AM)Always_In_The_Moode Wrote: The other day, I experimented with Apple Music streaming via AirPlay to Moode. I found that it sounded quite 'thin', as if something was missing.

When I streamed Apple Music lossless via my DAP directly to the sound system, it was a lot better.

I will use AirPlay for the rare occasions I need wireless convenience as I do with Bluetooth, not when I want to sit down and immerse myself in enjoyable listening sessions when quality absolutely matters to me.

If AirPlay was essentially nothing more than an AAC stream, then my observations would make complete sense.

I would love to do this but my bedroom speaker system is a large boombox with a subwoofer connected to a moode rpi through a lovely USB sound card. I could simply connect that sound card to my laptop, but I really want things to be wireless because of how convenient it makes everything..
Reply
#12
It sounds like the Apple Music app is making the decision whether to encode the Airplay stream using lossless ALAC compression or lossy AAC compression. Even with AAC though it looks like 256 kbps compression is being used which should in theory be perceptably indistinguishable from lossless. You best bet would be search the Internet for info on what exactly is going on with Apple Music.

The Shairport-sync receiver included with moOde just decodes whatever it's sent. If it happens to be an ALAC encoded stream then the so called "Hammerton" ALAC decoder is used https://github.com/mikebrady/shairport-s...ter/alac.h. It was written by David Hammerton and is the default ALAC decoder included with shairport-sync. After Aople eventually published its own code for ALAC as Open Source it was offered as a compile-time option for Shairport-sync but since it's simply redundant we don't use in our compile.

Here's some additional links
https://github.com/mikebrady/shairport-sync/issues/1205
https://audiophilestyle.com/ca/bits-and-...lay-r1026/

For your usage scenario where you want to stream 100% lossless from an Internet Music Streaming service to your audio devices over your local WiFi network it looks like the Apple Music solution might not be a good fit.

You could test Amazon Music HD. From what I can tell on my Mac the system-level Airplay transmitter is outputting 16/44.1K but its not explicitly showing what compression codec is used for transmission however it can infer from Shairport log below that it's using ALAC.

Code:
# Startup mode
pi@sig:~ $ cat /var/log/shairport-sync.log | grep Startup
        0.000281296 "shairport.c:2248" Startup in AirPlay 2 mode, with features 0x405fca00,0x1c340 on device "dc:a6:32:02:85:04".

# Decoder used
pi@sig:~ $ cat /var/log/shairport-sync.log | grep Decoder
        0.000053648 "dbus-service.c:1020" >> ALACDecoder set to "hammerton"
        0.000240982 "player.c:169" Hammerton Decoder used on encrypted audio.

# Log segment
       0.000029407 "player.c:2235" Play begin
        0.000036167 "rtp.c:1409" Connection 1: NQPTP master clock 3ccd3660210a0008.
        0.009156166 "player.c:450" Connection 1: synced by first packet, seqno 40307.
        0.000240982 "player.c:169" Hammerton Decoder used on encrypted audio.
        0.000126778 "player.c:1097" Accepting packet 40307 with timestamp 2567980457. Lead time is 2.008912 seconds.
        0.000045166 "player.c:1171" Connection 1: Lead time for first frame 2567980457: 2.008901 seconds.

Some screenshots
         

In the above example the Amazon HD track is 24/192K FLAC so I think we end up with the following pipeline

# Internet
Amazon HD source track 24/192K FLAC -> 
# Local MacOS (WiFi)
Amazon HD app + MacOS transcode 24/192K FLAC to 16/44.1K PCM ->
MacOS Airplay sender encodes 16/44.1 PCM using ALAC and streams to shairport-sync Airplay 2 receiver ->
# Raspberry Pi (WiFi)
Shairport-sync Airplay2 receiver decode ALAC to 16/44.1K PCM for output to audio device
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#13
Looks purrrfect to me, although simply just another Apple-pie...
Reply
#14
(07-31-2023, 03:52 PM)Tim Curtis Wrote: It sounds like the Apple Music app is making the decision whether to encode the Airplay stream using lossless ALAC compression or lossy AAC compression. Even with AAC though it looks like 256 kbps compression is being used which should in theory be perceptably indistinguishable from lossless. You best bet would be search the Internet for info on what exactly is going on with Apple Music.

The Shairport-sync receiver included with moOde just decodes whatever it's sent. If it happens to be an ALAC encoded stream then the so called "Hammerton" ALAC decoder is used https://github.com/mikebrady/shairport-s...ter/alac.h. It was written by David Hammerton and is the default ALAC decoder included with shairport-sync. After Aople eventually published its own code for ALAC as Open Source it was offered as a compile-time option for Shairport-sync but since it's simply redundant we don't use in our compile.

Here's some additional links
https://github.com/mikebrady/shairport-sync/issues/1205
https://audiophilestyle.com/ca/bits-and-...lay-r1026/

For your usage scenario where you want to stream 100% lossless from an Internet Music Streaming service to your audio devices over your local WiFi network it looks like the Apple Music solution might not be a good fit.

You could test Amazon Music HD. From what I can tell on my Mac the system-level Airplay transmitter is outputting 16/44.1K but its not explicitly showing what compression codec is used for transmission however it can infer from Shairport log below that it's using ALAC.

Code:
# Startup mode
pi@sig:~ $ cat /var/log/shairport-sync.log | grep Startup
        0.000281296 "shairport.c:2248" Startup in AirPlay 2 mode, with features 0x405fca00,0x1c340 on device "dc:a6:32:02:85:04".

# Decoder used
pi@sig:~ $ cat /var/log/shairport-sync.log | grep Decoder
        0.000053648 "dbus-service.c:1020" >> ALACDecoder set to "hammerton"
        0.000240982 "player.c:169" Hammerton Decoder used on encrypted audio.

# Log segment
       0.000029407 "player.c:2235" Play begin
        0.000036167 "rtp.c:1409" Connection 1: NQPTP master clock 3ccd3660210a0008.
        0.009156166 "player.c:450" Connection 1: synced by first packet, seqno 40307.
        0.000240982 "player.c:169" Hammerton Decoder used on encrypted audio.
        0.000126778 "player.c:1097" Accepting packet 40307 with timestamp 2567980457. Lead time is 2.008912 seconds.
        0.000045166 "player.c:1171" Connection 1: Lead time for first frame 2567980457: 2.008901 seconds.

Some screenshots
 

In the above example the Amazon HD track is 24/192K FLAC so I think we end up with the following pipeline

# Internet
Amazon HD source track 24/192K FLAC -> 
# Local MacOS (WiFi)
Amazon HD app + MacOS transcode 24/192K FLAC to 16/44.1K PCM ->
MacOS Airplay sender encodes 16/44.1 PCM using ALAC and streams to shairport-sync Airplay 2 receiver ->
# Raspberry Pi (WiFi)
Shairport-sync Airplay2 receiver decode ALAC to 16/44.1K PCM for output to audio device

Thank you for the exhaustive report! I did a little bit of digging myself and found that my Mac's Airplay output tops out at 800-900kbps, which is less than the bitrate of my 24/48 FLAC files. 

So I can get 16/44 output from local FLACs, which is a huge relief. At least my Mac is outputting at max bitrate. Will try to figure out what Apple Music's deal is.
Reply


Forum Jump: