Emulating Radio

Topics:
Internet Radio
MP3 Streaming

Internet Radio

If you do a Google search for "internet radio" the top two results are what we examined briefly in our first class:

  • Live365
  • Pandora


  • What is interesting is that they couldn't be more different from one another.

    Pandora is an algorithmic system which plays music specifically for you based on your likes and dislikes. You simply put in an artist or song name and go from there. It pays attention to what you say you like and dislike and goes from there.

    Pandora is also very much a showcase for a project called the Music Genome Project which is an attempt to classify music by quantifying aspects of the music (more than 400 different attributes) by experts.

    Live365 is a service for broadcasters as well as a directory for users to find the stations (should we still be using that term>). It ranges from a cheap service ($9.95/month) to a "pro" service.

    The tension between the two is very interesting, one is using a kind of AI and the other is "programmed" by whomever would like to. Human filtering vs. algorithmic filtering. Possibilities for live interaction with other peopole to no possibility of live interaction and so on..

    Of course, traditional radio stations have hopped on the bandwagon in a big way: CBS Radio Stations, Clear Channel New York Stations.

    DMCA

    We can't talk about internet radio without discussing The Digital Millenium Copyright Act (or DMCA).

    The DMCA is a law passed in 1998 which among other things defined two types of internet radio (interactive and non-interactive) as well as set the ability for a royalty rate to be put into effect for non-interactive stations that play music.

    This royalty rate has been going through the courts and various arbitration boards for some time but the current rates are set at:

    2006 - $0.0008 (per listener per song)
    2007 - $0.0011
    2008 - $0.0014
    2009 - $0.0018
    2010 - $0.0019
    with a minimum annual fee of $500.

    An organization called SoundExchange was created to collect the royalty payments on behalf of the copyright holders of the record recordings. (In addition, radio stations must also pay royalties to organizations that hold the copyright of the musical composition itself (BMI, ASCAP and SESAC).

    These royalty rates are highly controversial as they are very different for over the air broadcasters and can add up very quickly. A station which plays 10 songs an hour to 10 listeners would owe: $1576.80 ($0.18 per hour or $4.32 per day). If you double your listeners, you double your costs: $3153.60.

    More Information:
    Interview with Tim Westergren of Pandora regarind royalty rates
    Copyright Royalty Board

    MP3 Streaming

    In 1999 a company called NullSoft (famous for WinAMP) developed SHOUTcast which allowed the psuedo streaming of live audio via an HTTP connection.

    Around that time, the MP3 format was quickly becoming the defacto digital audio standard as it was widely supported by both hardware and software players (WinAMP, QuickTime, iPod and so on). (Something that is just starting to occur in the digital video space with H.264)

    Streaming via HTTP removed a couple of the issues that had previously plagued audio streaming. Those were getting through Firewalls (such as those setup by corporations to conserve bandwidth) as well as allowing the use of a less proprietary format (at least more commonly in use).

    While other audio streaming formats still exist MP3 streaming probably became the most common (RealAudio, Windows Media Audio, AAC and so on).

    NullSoft was purchased by AOL and it seems that the SHOUTcast server is now harder to find.

    ICEcast

    Icecast is an open source version SHOUTcast developed by the same folks who are developing the Ogg Vorbis open source codecs. Icecast uses the same protocol that Shoutcast uses to stream: ICY (I Can Yell).

    SHOUTcast and Icecast use a model which is include a source, server and client or broadcaster, server and client to stream.

    Source Clients/Broadcasters

    There are many SHOUTcast/Icecast source clients (broadcasters): Icecast 3rd Party Source Clients but we will be initially concentrating on using Nicecast which is a Mac only and very professional solution ($40 or free 20 minute broadcast limited demo). (If you are using a PC, I urge you to download and try one of the alternatives).

    We have an Icecast server setup on the Asterisk machine. The configuration settings you need to connect to it from any Icecast source client are on the Wiki.

    Clients/Players

    There are a wide variety of clients that can playback MP3 streams (itunes, winamp, quicktime, flash, windows media player and so on..). The key is getting the link correct.

    The easiest way is to link to an M3U (MP3 URL) file. Icecast automatically generates one when someone requests a "mount-point" with a .m3u on the end: http://asterisk.itp.tsoa.nyu.edu:8000/whatever.m3u

    This will cause the stream to open in the default player on the user's machine (such as iTunes or Windows Media Player).

    You can also embed a player on a webpage:
    QuickTime
      <OBJECT CLASSID="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" WIDTH="160" HEIGHT="144" CODEBASE="http://www.apple.com/qtactivex/qtplugin.cab">
    	  <PARAM name="SRC" VALUE="icy://asterisk.itp.tsoa.nyu.edu:8000/whatever" />
    	  <PARAM name="AUTOPLAY" VALUE="true" />
    	  <PARAM name="CONTROLLER" VALUE="true" />
      <EMBED SRC="icy://asterisk.itp.tsoa.nyu.edu:8000/whatever" WIDTH="160" HEIGHT="144" 
      AUTOPLAY="true" CONTROLLER="true" PLUGINSPAGE="http://www.apple.com/quicktime/download/">
      </EMBED>
      </OBJECT>
      		
    Note that with the QuickTime player you have to use the "icy://" protocol as the src (in two places in the above code and not use the .m3u extension.

    Example:

    There are a bunch of other attibutes that you can use when embedding the QuickTime player such as "HIDDEN" to make it invisible to the user.
    Flash
    Flash is a great option for playing MP3s off of a webserver (via HTTP). Unfortunately it has some issues with SHOUTcast/Icecast streams due to how it is built.

    It assumes that the file is going to be relatively small and therefore buffers the entire thing in memory. With a SHOUTcast/Icecast stream, this could mean buffering forever and therefore crashing the user's computer at some point.

    None the less, Flash because it is so ubiquitous is probably still a good option for live audio interaction. Here is the ActionScript for a very very very simple Flash player (no interface):
    package 
    {
    	import flash.display.Sprite;
    	import flash.media.Sound;
    	import flash.media.SoundChannel;
    	import flash.net.URLRequest;
    	import flash.display.LoaderInfo;
        
        public class SuperSimpleMP3Player extends Sprite
        {
        
            // Streaming URL from flashvars
    		private var streamURL:String = stage.loaderInfo.parameters.streamurl;
    
            // Sound Channel to monitor
            private var song:SoundChannel;
            
            // Request object for obtaining mp3 stream
            private var request:URLRequest
    
            // Sound... Factory for initializing our stream
            private var soundFactory:Sound;
    
            public function SuperSimpleMP3Player()
            {
                var request:URLRequest = new URLRequest(streamURL);            
                soundFactory = new Sound();
                soundFactory.load(request);
                song = soundFactory.play();
            }
        }
    }		
    		
    (In order to use this in Flash, it will probably take some modification but the key is the URLRequest object, the Sound object with the load and play methods.)

    Modified from: Creating a Simple MP3 Player using ActionScript 3.0 and Flex 2

    You can download a pre-compiled version of this: SuperSimpleMP3Player.swf

    Here is how you would embed it:
    		
    <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
    codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
    WIDTH="10" HEIGHT="10" id="myMovieName">
    	<PARAM NAME=movie VALUE="SuperSimpleMP3Player.swf">
    	<PARAM NAME=quality VALUE=high>
    	<PARAM NAME=bgcolor VALUE=#FFFFFF>
    	<PARAM NAME=flashvars VALUE="streamurl=http://asterisk.itp.tsoa.nyu.edu:8000/test">
    <EMBED src="SuperSimpleMP3Player.swf" quality=high bgcolor=#FFFFFF WIDTH="10" HEIGHT="10" NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" flashvars="streamurl=http://asterisk.itp.tsoa.nyu.edu:8000/test"></EMBED>
    </OBJECT>
    


    Example:


    I changed the background color to black so we can see it..