This post discusses how to distribute music to a collection on locations around a single house, but it works equally well for distributing music across the internet since it involves creating an internet-based streaming "radio station" using icecast, as well as Airtunes.
Last weekend my wife Krys threw a party for me. Like any party you have yourself, it was a bit frustrating since there is so much greeting and running around to do that I didn't get much chance to spend much quality time with anybody, and everybody there was somebody I would have liked to sit and talk to.
I had hoped to get people dancing (and failed), but as an aside I arranged to broadcast music around the house to several locations on 2 floors. To do this, I used iTunes (on a Mac) to produce a playlist. The problem then, was how to distribute a synchronized playlist to at least 3 locations within the house. As an aside, I wanted to use icecast (i.e. shoutcast) so I could do other stuff as well like (later on) broadcast outside the house. The Shoutcast protocol can be used to broadcast to Macs, Windows, Linux, FreeBSD and Solaris (and more). Shoutcast is freeware while the compatible Icecast (or Icecast2) is true GPL (and I believe it was released before Shoutcast became free).
Option 1: Use Airport Express: The easiest way to do this is to use airport express wireless "bricks". You can broadcast to these easily from iTunes, and it it just works. My problem was that I didn't have enough Airport Express bricks; some locations had to be actual computers, but iTunes does not support broadcasting to another computer.
Option 2: Use Airfoil: There is a software package called Airfoil. This allows you to capture the audio output (from any program) and broadcast it to an Airport Express unit, or to a mac or Windows computer running their free Airfoil Speakers application. It's very nice and only costs $25. Being a bit of a hard-core hacker, I was interested in an icecast solution I could roll myself, for several reasons including the fact it would allow me to subsequently broadcast content over the internet, for example to my office.
Option 3: Roll my own Icecast2 server: this is obviously what I chose to do. It turned out to be a lot harder to figure out than I expected and had I been less reluctant to admit defeat and more practical, I would simply have purchased Airfoil. On the other hand, it's pretty easy once figured out and I needed some hacking-based stress relief. Read on for the recipe.
How to create an Icecast Broadcasting Station on OS X
Internet streaming radio is normally based on Shoutcast or the compatible GPL software called Icecast. Icecast software runs on Apple's OS X as well as Linux an it's what I used. This method can also be using with Airtunes (normal iTunes bradcast to Airport Express) at the same time.
Requirements: OS X, Apple Developer tools, http://www.macports.org/. If you use my precompiled binaries (below) you might get away with all these tools if you are lucky.
To feed content into Icecast, you need one of several programs depending on the format(s) you plan to use (such as MP3 or Ogg Vorbis) I selected Darkice and the MP3 format since I had prior experience with darkice, and like the universality of mp3, and because darkice runs on Linux and OS X, and is pretty solid.
Darkice pulls in data from either a fixed file, or from an input device (like a microphone). I was using iTunes so I needed to re-route the output from iTunes to create a vartual input device for darkice to listen to. To do this,
I used a pair of tools I discovered. This learning process sucked time, but was quite useful for other projects. To do this I used Soundflower and Jack. Soundflower grabs and input (or output) and Jack allows the output from Soundflower to to connected as a virtual input to ay other program.
Soundflower V 1.3.1 is available via macupdate.com/ or thirdcog.eu. Jack is available at http://jackaudio.org/ and can be downloaded directly from Sourceforge.
A diagram illustrating all this is shown here.
Note that darkice and icecast2 have slightly complex-looking XML setup files, but nothing exotic needs to be done in the setup. Example setup files provided
here should work fine for you, and they're called icecast.xml and darkice.cfg.
To configure and control Soundflower, which is a kernel module, you should use the application program (app) called Soundflowerbed. The program Jackpilot that comes with Jack can be used to control it, but all you actually need to do with it is start Jack. WARNING: I also tried to install Jack using macports as a command-like tool, but the resulting code was incompatible with darkice and had to be completely removed to get things working!
To install darkice and icecast2 you can use macports (i.e. port install darkice and port install icecast2). If you don't know about macports, you should. If you can't figure that out, then this approach isn't for you anyhow, and you should buy Nicecast and/or Airfoil.
How to make it go:
In the normal Sound control panel, set the output to be Soundflower (2ch). With soundflowerbed, you can optionally route the 2ch audio to the hardware output device (speakers) as well, to help you hear what's happening.
Run Jackpilot and start Jack.
Run icecast using:
icecast -c icecast.xml &
Run darkice from the terminal using:
darkice -c darkice.cfg &
Play music with iTunes.
Listen to it from another computer using iTunes by using the Menu item Advanced>>Open Audio stream
and enter something like
http://188.8.131.52:8000/stream96 with the number 184.108.40.206 should be replaced by the IP address or name of the computer doing the broadcast.
Instead of Soundflower it seems like you can use ESD, the Enlightnment Sound Daemon (which is commonplace on Linux). These posts provide an alternate solutions based on esd.
Darkice config files are explained here.
Pre-Compiled versions of darkice and icecast for OS X Leopard are available here is you want to try skipping their installation (they were compiled for OSX 10.5.5 and may not work if your computer is configured differently from mine.)
Soundflower is also available at cycling74.com and they appear to be the original developers, but only provide an older version.
The full scoop on Icecast, from installation to history can be found in the on-line book by Kerry Cox.
In you get into Internet radio, a list of stations can be found at dir.xiph.org (in addition to those built into iTunes).
Audio Hijack can also be used to capture audio on OS X.
[ Followup, Feb 2010: for Snow Leopard, you may want to install Jack version 0.83 or better.
Be careful with a combination of multiple jack installations.. The dmg from the Jack web site installs jack in one place (/usr/local) while the macports version installs it someplace else (/opt/local). If both are installed you can end up with strange problems, like a version of darkice that has a problem opening jack and doesn't work. ]
Another blogger has provided a very clear page on this process with some additional details http://blog.joshdzielak.com/blog/2012/11/21/live-stream-audio-from-osx-mountain-lion-with-icecast-and-darkice/