Avoiding the analog: Icecast2 for OS X, Sonos & Spotify Radio

Apparently, Spotify has finally released their Radio API to certain content management platforms, but until it’s built into Sonos the only way to actually get Spotify Radio on my ZP80 was to use the analog line-in.  What about creating an Icecast (Shoutcast, Podcast, etc.) local radio station that I tune in to on the Sonos locally? This would then avoid the analog hole (until I add a phonograph line stage).

There were a few sources I had to use to make this work, and I’ve only built/tested this under 32 bit 10.6.8 Snow Leopard (so your mileage may vary for 64 bit and/or more modern OS X machines).  Joao Ricardo’s blog post of  “Icecast Radio in Mac OS X” turns out to be a great starting point.  Note, that he recommends installing MacPorts, which may not strictly be necessary if you have Homebrew already installed.  I have not tried to port Icecast via Homebrew, but I imagine the installation would also work, as others have had success.   For example, here’s Josh Dzielak’s tutorial for Icecast & Darkice using Mountain Lion and Homebrew

So yes, per Joao’s instructions:

1) Install MacPorts (note: there are several dependencies, read up before you even install MacPorts)

2) In Terminal$: sudo port install icecast2

  • If doing Homebrew$: brew install icecast
  • Icecast vs. Icecast2?  I don’t know. You tell me internet, you tell me.
  • This took like 30 minutes using MacPorts on an old 32 bit Intel machine

3) Install Ladiocast.

4) Install Soundflower.

  • Reboot machine.

5) Make sure your admin/user has access/rights to “icecast -c /usr/etc/icecast.xml” as well as wherever an error for Icecast’s “access.log” and “error.log” files.  In my case they needed to added to /opt/local/etc.  You’ll need to adjust access with “chmod 755″ in this example.

6) Start playing some music on your Icecast server machine.  In OS X “Sound Preferences” make sure “Soundflower 2ch” is set as the “output device”; you can also “option + click” on the volume in the at the top right menu and select the source.

7) From Terminal$: icecast -c /usr/etc/icecast.xml

  • At this point Terminal will need to be open, obviously you can set this up as a background process, run on startup, etc. see Josh’s article linked above.

8) From within Ladiocast choose “Soundflower 2ch” as your source, click on the “main” button in Ladiocast.  You should see music bars making music.

  • From the menu in Ladiocast click on “Streamer 1” choose Icecast.  Set 127.0.0.1:8000 or whatever you machine’s IP is for the server.  The default user and pw is located the XML file.
  • For encoding, especially to work with iTunes and probably Sonos, I set it to AAC 320 kbps.  Ogg may in fact work with Sonos, I’ve not tried it.
  • Click “Connect” at the bottom there.

9) In a web browser, type in the IP for the Icecast server.  If said machine is localhost use 127.0.0.1:8000 which is the default port for the service. Click on the .m3u link and open in iTunes/Winamp or similar.  If you have music bars making music and you have a .m3u created you should hear music (double check OGG vs. AAC).

10) Final step: open the desktop Sonos App. Click “Manage” from the menu bar and then “Add Radio Station” and the enter http://127.0.0.1:8000/stream.m3u (or whatever your IP is for the Icecast machine).  Create that as a favorite radio station.

11) Works for me.  If you want an Icecast radio station globally on WAN, well, poke those holes. Google a bit.  That’s not this blog entry.  Let’s hope Sonos adds Spotify Radio sooner than later.