Monday, October 13, 2008

Internet Radio Station

Internet Radio

Today we want to take a first look at Internet broadcasting, but not necessarily the creation of podcasts, which when you strip away the jargon are just recorded audio files - usually just some talking head. Good for listening to lectures on the bus possibly but pretty boring most of the time. What is more interesting is the concept of replacing amplitude modulation or frequency modulation transmission methods for radio with broadcasting over tcp/ip. A mac server using the included quicktime broadcaster would be a good way of proceeding but let's see if we can do this on the cheap.

Looking through the storage bins we came up with a bag full of old mac microphones - the ones that also work on PC's. So we can set up the class with mics for recording their voice-overs and carts. We also have a bunch of audio content already in MP3 format as the test files for the web class - including songs, speeches, sound effects etc. All we have to do is set up a steaming audio server and design our show.

We are going to start with Windows first and then see how it can be done on Linux. The first requirement is something to steam audio in MP3 format.

So we head off to http://www.icecast.org/ the home of the open source Icecast project. Their home page says "Icecast, the project, is a collection of programs and libraries for streaming audio over the Internet". This includes:
  • icecast, a program that streams audio data to listeners
  • libshout, a library for communicating with Icecast servers
  • IceS, a program that sends audio data to Icecast servers
They have download versions for windows, red hat (.rpm) and a generic tarball which would what we will use later with Ubuntu. I see there is some user-contribute howtos that will be usedful later such as the ogg vorbis howto and a long article by Kerry Cox on open source audio streaming.

For now we download and install the Windows version which installs itself as a windows service. This means you can administer the service through the control panel, administrative tools, services applet. The default is to set the icecast service to automatic which makes sense for a server. Since this is running on my sub-notebook we change this to manual for now. If you do this you have to tick the checkbox Start Server on Application Startup in Icecast.

The program installs itself to C:\Program Files\Icecast2 Win32 which contains the configuraion file called icecast.xml which we open in the Notepad text editor. For doing a demonstration we problably want to 'lighten' the load on the mini book.

For example, i've reduced the number of clients from the default of 100 down to 10 and made some other changes. Also enabled burst mode, changed the source/relay passwords and setup the admin user password. I left the directory listings commented so that functionality is disabled for now. Port 8000 was set up for multiple connections.

After we save the file we run Icecast. Since we had set the service to manual we had to click the Start Service button which immediate brings up a windows security alert from the windows firewall. Click Unblock to allow Icecast to proceed. You can actually edit your configuration inside the program.

Once we verified the icecast server program is running ok we n0w need some broadcasting tools for the audio. The idea is to play the audio and send it to the icecast server for streaming. We don't want to a bloated program like windows media player (which we disabled anyway) because we prefer Winamp, especially the lite version on Windows with the dumb visualizations turned off.

There was a neat plug-in called oddcast. So off to http://www.oddsock.org/tools/edcast/ we go. The web site says:

"Edcast is a broadcasting application targeted to the small station owner. There are three different flavors, a Winamp plugin, a Foobar plugin, and a standalone broadcaster".

This give us some choices. Since we already have winamp lite version 5.xx we can try the old oddcast plugin and see how it goes - and if that is no good then try the standalone edcast program. So we install oddcast version 3.xx and choose the default install. Note that this comes with an option for the Lame mp3 encoder but that it cannot be included for legal reasons.

We right click on winamp and select Options, Preferences from the menu. In the plug-in section we select DSP/effect and choose Oddcast. The configuration dialog box for the plug-in appears.

The problem here is that only the ogg vorbis encoder appears so that all audio will be streamed in that format. Since all our content is in MP3 format that is no good. Looks like we have to install the lame MP3 encoder.

So we need to reinstall oddcast. First we search the web and download out_lame162 which is a lame encoder plug-in for winamp and install. The installer works but returns a warning:

Quality value setting is broken in 3.96.1. Use presets to set quality of use 3.97.4

Let's see if we can use presets to get an acceptably low bitrate for streaming. If not we have to get the newer version. However, it doesn't even turnup as a plugin in winamp s o we go back to the oddcast and select lamp this time. We download the lam_enc.dll and copy it to the winamp program directory.

Now we run winamp again and right click and select Options, Preferences from the menu
Then we click on the oddcast dsp.
You have to move to (none) and then back to Oddcast to bring up the configuration box
Clicking the Configure active plug-in button did nothing
Select the encoder setting and right click. Select Configure from the menu

We select the existing encoder entry (ogg vorbis) and right click to bring up the properties. For encoder type we select MP3 instead of ogg or flac. As warned the quality box is greyed out so we manually select a bitrate of 96 with a mono channel with a sampling rate of 22050 about half of the normal rate.

5512 Capable of telephone quality audio
11025 Capable of radio quality audio
22050 Reasonable fidelity
44100 CD quality

The idea was to get it working first and then see about optimizing the sound. The oddcast panel also has a live recording feature so you can broadcast voiceovers or commericals or 'radio personality' chit-chat. We hooked up a gooseneck clarad mic to the mic input jack on the laptop.

Once confusing item is the mount point of /stream.ogg - it is not clear what this refers to. I changed it to /stream.mp3 and clicked ok.

Ooops- better figure out the IP address of the laptop. Drop to DOS and type ipconfig and see it is running on 192.168.1.110 on the wireless and 192.168.1.108 on the wired. Will we be broadcasting on both? Stay tuned...Best load up some content - we goto winamp and load the classic 'green eggs and ham'.

We now click the Connect button and goto the linux box and type:
http://192.168.1.108:8000/stream.mp3

Success!

We can hear the bedtime story. It buffers the audio and actually sounds quite good. Will have to test with some music later - load up the laptop with tunes. We also want to test the connection with a number of different machines listening to see the load on a light laptop.

Interesting to see how the streaming works. I stopped playing the file on the laptop and it was eerie to still hear it playing on the desktop next to it. I then used the live recording function with the mic to create a short promo. The neat thing is the promo is not heard by the client until the green eggs and ham story was finished. Streaming means there is a steam of data being sent out. Obviously this affects how you setup your show. Do you record everything at once or combine bits into a single audio file or more likely set up a playlist in winamp or even do a random shuffle (with repeats or no repeats) of MP3 files in a directory. Takes me back to Acadia radio in college.

More later - time for some dinner

Weird thing - i decided to switch laptops to use the full-size machine. Icecast installed but winamp crashed on install a couple of times. I only got it to install by delselecting all the options. I then installed and configured oddcast and setup a playlist. Everything looks ok but the web browser could not find the mount point file of /stream.mp3 that i had specified in oddcast.

Checking the oddcast configuration in winamp i noticed it was constantly disconnecting and reconnecting. If winamp was stopped it connected but when the playlist was playing it kept timing out and trying to reconnect. Nothing seemed to solve the problem - i checked the config settings for everything against the working version. Then i copied the plugin directory from the working mininote and ran winamp again. An error message of libsnd.dll not found was displayed but the program ran and oddcast connected and the mp3 stream was ok. The web browser now connected and found the mount point. There was funny business with quicktime, the app associsted with the stream on the client - it would only play a few seconds and i could not get two clients to connect.

1 comment:

Jun aka Fangaliel said...

Hello.
I had the exact same event.
Oddcast dsp for winamp was doing its thing just fine to do live streaming...until one day it started doing the same thing : Disconnecting when music is played in winamp and connecting if nothing plays in winamp. I didn't do any changes in whatever option either.
I can't find a solution. Would you have found one please ?
Thanks,
Fangaliel