Table of Contents
If you have high-end headphones and insist on listening to lossless streaming music on Linux, you could use a tricky way to listen to loseless Apple Music on Linux! Runnning the Android version of Apple Music through Waydroid container on Linux.
1. Literature review#
Apple Music is a subscription-based music streaming service launched by Apple. In addition to the basic AAC 256kbps, it also provides lossless sound quality streaming.
There are two so-called “lossless sound quality”:
- Loseless, 24bit/48kHz
- High-res loseless, 24bit/192kHz
The Apple Music app supports both iOS and Android. For listening to Apple Music on your computer, iTunes or Apple Music preivew is required. And iTunes only supports Windows and macOS.
What about Linux? Running iTunes thorough Wine? Latest version of iTunes is quite unstable on Linux. It does not work at all.
Use KVM Windows virtual machine to run iTunes? No no no It costs too much just to listen to music!
Use Apple Music web? Not good. It does not support lossless output.
How about Cider? That is just a “wrapper” for the Apple Music web, and it also does not support lossless output.
The funny thing is, when I was googling how to listen to Apple Music on Linux, I saw some scams. Some software manufacturers tell you to use their software to convert (record? pirate?) the music of Apple Music into mp3 so you can listen to them on Linux! …ah if I download the music then what’s the point of listening to streaming music?
Alas, it’s so painful. Even Linux Hint advertise proprietary software like TunesKit. Ha, didn’t they you know that TunesKit does not even support Linux at all?
So I thought of using the Waydroid container to run the Android version of Apple Music. Voila! Everything works great.
2. Change the sampling rate of PipeWire#
OS: Arch Linux 6.5.9, KDE 5.27.9 (Wayland)
PipeWire is a new Linux audio system, backward compatible with the old PulseAudio server. The default sampling rate of PipeWire is 48kHz, and we need to increase its sampling rate to 192kHz, which is the highest sound quality of Apple Music.
It is worth noting that to have a external DAC connected while listen to music with a sampling rate of 48kHz or above.
Execute the command
pactl infoto confirm that PipeWire is currently used.
...on PipeWiremeans that PipeWire is currently used.
/etc/pipewireand edit it
sudo cp /usr/share/pipewire/pipewire.conf /etc/pipewire
sudo vim /etc/pipewire/pipewire.conf
- Modify as follows, fill in
default.clock.ratewith 192kHz, and fill in
default.clock.allowed-rateswith all available sampling rates according to your preference.
default.clock.rate = 192000
default.clock.allowed-rates = [ 44100, 48000, 88200, 96000, 176400, 192000, 352800, 384000 ]
- Restart the PipeWire service
systemctl restart --user pipewire.service
systemctl restart --user pipewire-pulse.service
pactl infoto check whether the change has been applied.
3. Install Apple Music#
Install Waydroid, currently it’s on Android 11.
Apple Music has an x86 version, which can be downloaded directly from the Play Store.
Log in to your Apple ID and check Lossless sound quality in settings.
pw-topcommand to check on the sampling rate on Linux side. Sadly, although Apple Music can have 192Hz output (ALSA), the audio sampling rate output by Waydroid to the Linux side is only 48Hz (limitation of Android SRC itself). At least this matches the standard of loseless audio (24bit/48kHz).
Other than that, everything works fine, including lyrics.
Consider enabling multi-window mode of Waydroid. In a well-supported Wayland environment, you can freely adjust the layout size of Apple Music app.
4. My attmept to remove Waydroid 48kHz limitation#
Audio playback architecture:
Apple Music → (Android) Waydroid → PipeWire → DAC
Now it should be a problem of Waydroid itself.
Or manually modify the Waydroid
vendor.img file and put the file modified by lineage-audio-mod into the Android system:
git clone https://github.com/nyarla/magisk-lineage-audio-mod.git
sudo systemctl stop waydroid-container
# Adjust vendor.img size
sudo dd if=/dev/zero bs=1MiB of=/var/lib/waydroid/images/vendor.img conv=notrunc oflag=append count=512
sudo e2fsck -yf /var/lib/waydroid/images/vendor.img
sudo resize2fs -f /var/lib/waydroid/images/vendor.img
sudo mkdir vendor
# Mount and move files into it
sudo mount -t ext4 -o loop,rw /var/lib/waydroid/images/vendor.img vendor
sudo cp magisk-lineage-audio-mod/system/vendor/etc/* vendor/system/vendor/etc/
sudo umount vendor
sudo systemctl restart waydroid-container
After restarting Waydroid, install Sample Rate Checker and see that the supported sampling rate is 192kHz
pw-top still shows that Waydroid output is only 48kHz.
As a result, if you really want to listen to 192kHz loseless audio, you may still have to run iTunes in a virtual machine.