Airplay Whole House Audio with Shairport-Sync and Forked-Daapd

I have HA running in a proxmox virtual machine on an intel nuc, pretty keen to stay with that.

Thanks for the tutorial.

Iā€™m trying to build a setup around Airplay, Spotify, local music files and a mobile front-end.

The elements would be:
1 - Media server that can combine local files with Spotify (and possibly other streams / services)
2 - forked-dappd (now owntone-server to stream to AirPlay speakers
3 - A Mobile front end to control media and playing (an MPD client or appleā€™s remote iTunes app)

One options is to use mopidy + Mopidy-Spotify as an spority + local integrated music server AND slimmed down version of owntone-server - without the iTunes library or mpd server. In this setup we need to stream from mopidy to forked-dappd but Iā€™m not sure the MPD clients or the remote iTunes app could mange changing streams / speakers.

Another option is to build around the full forked-dappd installation as the music server and integrated Spotify somehow (any ideas how to??) and use the remote iTunes app as a client using this script (un-tested)

Thoughts ???
Happy to work on something like this with you if you like.

Nadav

forked-daapd can be built wilth support for spotify, but not sure if the docker version I use has the option. You could install the native forked-daapd with the option:
--enable-spotify

I think forked-daapd (owntone) does all of that already, no?

Fantastic tutorial. Thank you! This solved an issue Iā€™ve been wanting to take care of for years.

If I could make some notes & additions:

  • Some of your shairport-sync.conf entries have no semicolons. (Not a big deal but could save someone a lot of head scratching.)
  • More streamlined to:
    • copy shairport-sync.conf
    • put it in /mnt/data/supervisor/share/shairport/shairport-sync.conf
    • make appropriate edits.
    • change volumes section of docker-compose from:
      - /mnt/data/supervisor/share/music:/music
      - /mnt/data/supervisor/share/shairport:/config

to

      - /mnt/data/supervisor/share/music:/music
      - /mnt/data/supervisor/share/shairport/shairport-sync.conf:/etc/shairport-sync.conf
      - /mnt/data/supervisor/share/shairport/scripts:/scripts
  • Unsure if itā€™s just something I didnā€™t get right but playing through the whole house airplay pipes my audio through two different sets of volume controls (phone & forked-daapd) resulting in cumbersome operation. You could use the forked-daapd api to change the volume but Mike Bradyā€™s image is built on busybox which doesnā€™t have curl. So we resort to this cludgy but effective workaround.
    • Add a file /mnt/data/supervisor/share/shairport/scripts/vol.sh . Contents:
#! /bin/sh

printf "PUT /api/player/volume?volume=$1 HTTP/1.1\r\nUser-Agent: nc/0.0.1\r\nHost: 127.0.0.1\r\nAccept: */*\r\n\r\n" | nc 127.0.0.1 3689
  • chmod 775 /mnt/data/supervisor/share/shairport/scripts/vol.sh
  • modify in shairport-sync.conf again
        run_this_before_play_begins = "/scripts/vol.sh 100";
        run_this_after_play_ends = "/scripts/vol.sh 33";
1 Like

Iā€™m trying to figure out how to make an AirPlay 2-compatible setup using my existing 6 zone whole-house audio amp (which I can control via Home Assistant and a network bridge). Iā€™ve read this thread but Iā€™m still not totally clear on whether this could give me what appears to users to be a ā€œnativeā€ AirPlay 2 style experience for people streaming music ā€“ that is, on an iPhone, in the Apple Music app (or whatever app they choose), a user can simply hit the ā€œairplayā€ button on the iOS overlay and select which rooms (multiple) they want the music played in, and control the volume for each room independently. Each room being a Raspberry Pi with AirPlay, connected to a zone on my multi-zone amp.

I donā€™t think this is possible without having an airplay device connected to each zone, such as 6 old airport express devices.

Airplay 2 wonā€™t happen Iā€™m afraid, they havenā€™t cracked the protocol yet. But that being said you really donā€™t need it. You can stream in perfect sync to Airplay 1 speakers just fine from forked-daapd and shairport-sync and control the volumes of the rooms individually. This will be done in the home assistant UI or in the Remote App, not via the overlay (the audio is not streaming from your device, so regardless of what media server you choose including iTunes, it will never use that overlay).

And if they are airplay 2 capable devices you can still use them just fine from you iOS device and select multiple speakers with mixing (which is the only place this really should matter).

So I donā€™t think this will be an issue you will even notice. It should find all of your speakers unless they arenā€™t backwards compatible to airplay 1, but I havenā€™t personally encountered any devices like that. All my airplay 2 devices support airplay 1.

After some more digging into forked-daapd, I understand that nowā€¦and I also understand that forked-daapd is not the solution for me. I do want peopleā€™s phones to be the device the audio is streaming from. So that anyone can use their Apple Music app like theyā€™re used to, and be the DJ ā€“ play in specific zones, adjusting volume, all without having to open another app or do anything other than join my WiFi network.

There is a bounty out for Shairport-Sync to be Airplay 2 compatible, and I know the developerā€™s looked at it a little bit, but yeahā€¦itā€™s probably aways off. I canā€™t believe there isnā€™t an official Airplay 2-compatbile accessory thatā€™s the equivalent of an Echo Input or Chromecast Audio for existing stereo systems.

Doesnā€™t Apple Music already do that!? Even if it supported AirPlay 2, it still wouldnā€™t work the way you describe because the music isnā€™t stored locally.

I donā€™t understand what you mean. What does storing the music locally have to do with it?

Yes, Apple Music can play to multiple AirPlay 2 endpoints (regardless of what the source of music is ā€“ library on the phone, streaming from Apple services, etc). You can control it right from the AirPlay overlay in iOS. Thatā€™s why Iā€™m trying to find some software or device that I can use to make my 6 zones around the house AirPlay 2 receivers. Shairport-Sync, if it were enhanced to support AirPlay 2, could do this (if I bought 6 Raspberry Pis). As it is today, I can AirPlay from iOS to my single (Airplay 1 compatible) Shairport Sync device, but then I have to hop over to the Home Assistant app to activate specific zone speakers and control their volume. If Shairport-Sync was AP2 compatible, that could be done from the iOS AirPlay overlay, provided you have a device setup for each zone.

I originally posted in here because I was a bit unclear about what forked-daapd does but I understand now that itā€™s essentially a drop-in replacement iTunes. Which is cool, but just doesnā€™t fit my use case. What I really need is Shairport-Sync to be AirPlay 2 compatible.

Apple music is an app that sitting on your phone streaming the music from your phone. iTunes, Forked Daapd, etc. are not. They will never work in the same way.

Anyhow, my music setup is far more intuitive with alexa and homeassistant as the UI then it ever was with Apple Music or Remote as the UI. I use my music about 20 times more than I used to. Iā€™m glad I gave up on Appleā€™s music ecosystem, it was really holding me back in terms of enjoying my music. But if you like Apple Music so much, why not just use that?

I guess you are just looking for something to fill the gap that Apple left with the abandoning of airport, yes? Probably your best bet is this, not cheap but thereā€™s really not much in the way of options here.

Shairport-sync now has basic airplay 2 support in beta if that helps you

Anyone dealt with sync issues with the Airplay 2 build of Shairport-Sync?

Iā€™m piping shairport sync (Airplay 2 dev build) to owntone as a way to add airplay 2 functionality to two Airplay 1 speakers, which works great, except that theyā€™re both out of sync by about 3 seconds (behind) all the real Airplay 2 speakers.

Iā€™m guessing the issue is that shairport-sync syncs the time correctly but the pipe and daapd add a few seconds of delay, and Iā€™m not sure how to fix it.

Maybe if daapd has a way to offset the sync by a given value I could fine tune it by a few seconds, as it seems to be a very consistent delay, but Iā€™m not sure if thatā€™s even possible.

Figured it out. For anyone who runs into the same problem, use shairportā€™s config.

This was mine:
audio_backend_latency_offset_in_seconds = -3.3;

Now audio is in perfect sync.

3 Likes

I did set forked-daapd (new name: OwnTone) up on Promox as a CT with ubuntu-18.04 as a template-base.
Using the guide from Github (https://github.com/owntone/owntone-server) was quite straight forward.

I did mount a CIFS/SMB Share to the CT/Ubuntu (my music resides on a network share / NAS).

The configuration was super easy, however I couldnā€™t start Owntone as described - Avahi Daemon was missing on the above Ubuntu Distribution.
Installing Avahi Daemon was required:

sudo apt install avahi-daemon

What I could not find are system requirements in terms of CPU/RAM/SSD

It is super lightweight as it turnes out:
CPU: 1
RAM: I have assigned 1GB but it could do with far less (256MB/512MB). Current usage: 62MB :smiley:
SSD: I have assigned 4GB but ATM it sits just below 2GB, lets see how big the DB gets once I do a rescan (I just added a couple of songs initially for testing)

I use it with airplay speakers, and it worked out of the box. Next thing now is to integrate the control into HA.

Thanks for the inspiration!!

So Iā€™m just looking at the HA integration of this. Its cool to have basic functionality (play/stop, next/previous), however what Iā€™m looking for is to browse through the media files and just play them (like I would with the App ā€œRemoteā€ from Apple to control iTunes.

Is there any way to do this?

Hey, I just set up owntone (still playing with it) and the forked_daapd integration in HA. One thing I noticed when I create a lovelace card to control owntone is that the ā€œSource Listā€ starts with ā€œDefault (no pipe)ā€ and then has the list of my playlists. Where is that ā€œDefaultā€ coming from, and how do I get rid of it? Iā€™m currently not planning to set up shairport-sync in front of owntone, so the only inputs would be the music library.

the SourceList actually refers to a list of playlists owntone has discovered upon library scan. Like, m3u playlists. And default means no playlist.

@ddppddpp ā€“

the SourceList actually refers to a list of playlists owntone has discovered upon library scan. Like, m3u playlists. And default means no playlist.

Thatā€™s what has me so confused. There are playlists that it finds/found, and they are in the drop-down list, below the ā€œDefault (no pipe)ā€ entry in the list.