AFDB logo
mn :: comp :: hardware

Radio Slimserver

How to play real radio through the Slimserver

Why? Because streaming Internet radio consumes a lot of bandwidth, which I'd like to use for other things. While Internet radio is great for picking up radio from around the world (thanks to AlienBBC!), it's kind of silly to stream the same content over the Internet that I could pick up from the air (KALX). Besides, many of the stations we want to listen to don't have Internet streamers anyway (or, like KFOG, they're not setup to stream through Slimserver well).

How? There are three steps:

  1. From the air into the computer: Connect a radio to your server's soundcard's line in. For testing purposes, I just ran a wire from the headphone jack on my stereo over to the input jack on my server, but in the long run I'll be wanting to use a more PC-friendly solution. Unfortunately, these days it's hard to find one of those in the States... I ended up buying a used D-Link DSB-R100 from craigslist, but I see that these and the similar Avermedia USB Radio are still available in the UK and Australia. I don't think Griffin RadioSharks will work for Linux but might be usable on a Mac or Windows. A PVR card or external cpature device would of course work, but is beyond the scope of what I'm trying to do here... just the radio, thanks. I used my Linux server with ALSA sound, so I needed to use alsamixer to set this up. Test connections with something like rec -s w -c 2 -r 44100 test.wav -- if you get a wave file that sox will play, you're ready for the next step.
  2. From the sound card to a stream: Install icecast and ices. There are dependencies on shoutcast and ogg vorbis libraries, use the resources on the Icecast site to get this all sorted if you don't have something like urpmi/apt-get/portage to figure it out for you. Configure them properly. I'm posting my configurations below, but they're only suitable for this sort of a dedicated purpose. If you want to operate multiple streams, use the Linux server as a sound-playing workstation, or do other fancy things like timeshifting shows, you'll want a more complex configuration. I may end up looking into another solution for this, ices is converting to Ogg Vorbis and apparently has no real equivalent to the lame switches for reducing CPU usage. No matter what quality level I choose, ices is taking about 25% of my CPU, so I'll probably switch to something that streams MP3 instead. UPDATE: I definitely need to do this, the OGG>MP3 conversion is causing my SliMP3 to lag behind my Squeezebox by about a second per hour.
  3. From the stream to the Slimserver: At this point, since I haven't received my hardware or written the controller plugin yet, all you can do is listen to whatever the sound card is picking up. To do that, simply create a playlist entry in Slimserver: 
    /usr/local/slimserver/playlists/localhost.m3u
    #EXTM3U
    #EXTINF:-1,stream.ogg
    http://localhost:8000/stream.ogg
    
    UPDATE: Got my D-Link USB Radio from Craigslist for $10 and plugged it in. The log showed that it had been auto-detected properly, so I chown'ed & chmod'ed the /dev/v4l/radio0 entry and downloaded fmtools. A few minutes later, I had radio... it works beautifully. Another fine script for timeshifting is fmcapture.
  4. UPDATE: I finally converted from Ogg to MP3. I tried ices0 but couldn't find adequate documentation to get it to do what I want, so I ended up on liveice-sn. Note that this is different than the original liveice, which doesn't work with icecast2. To make it work, I had to download the software, run configure, run make, and edit the Makefile. $(SRCDIR)mkdirs $(DESTDIR)... should go /usr/bin/mkdir -p $DESTDIR..., and the sample config file is actually named $(SRCDIR)liveice.cfg.dist. Here's my liveice.cfg:

    [root@felix root]# grep -v \# /usr/local/icecast/etc/liveice.cfg | grep -v ^$
    SERVER localhost
    PORT 8000
    PASSWORD hackme
    USE_LAME3 /usr/bin/lame
    ENCODER_ARGS -h
    SOUND_DEVICE /dev/dsp
    HALF_DUPLEX
    SAMPLE_RATE 44100
    BITRATE 128000
    STEREO
    ENCODING_QUALITY 100
    HTTP_LOGIN
    MOUNTPOINT stream
    NAME Radio Waves
    GENRE real frequency modulated electromagnetic spectrum
    PUBLIC 0
    URL http://www.monkeynoodle.org
    DESCRIPTION real frequency modulated electromagnetic spectrum
    NO_MIXER
    UPDATE_DELAY 5
    

    There's no launcher script, so I had to do this one -- also the no-interface option (-@2) causes it to crash.

    #!/bin/bash
    #
    # liveice      This shell script takes care of starting and stopping
    #              liveice streamer.
    #
    # chkconfig: 2345 55 10
    # description: liveice streams audio
    
    # Source function library.
    . /etc/rc.d/init.d/functions
    
    # Source networking configuration.
    . /etc/sysconfig/network
    
    # Check that networking is up.
    [ ${NETWORKING} = "no" ] && exit 0
    
    [ -x /usr/local/icecast/bin/liveice -a -f /usr/local/icecast/etc/liveice.cfg ] || exit 0
    
    # See how we were called.
    case "$1" in
      start)
            # Start daemon.
            gprintf "Starting liveice: "
            /usr/local/icecast/bin/liveice >/usr/local/icecast/log/liveice.log >&1&
            echo
            touch /var/lock/subsys/liveice
            ;;
      stop)
            # Stop daemons.
            gprintf "Shutting down liveice: "
            killproc liveice
            echo
            rm -f /var/lock/subsys/liveice
            ;;
      status)
            status liveice
            ;;
      restart)
            $0 stop
            $0 start
            ;;
      reload)
            $0 stop
            $0 start
            ;;
      condrestart)
        if [ -f /var/lock/subsys/liveice ]; then
            $0 stop
            $0 start
        fi
        ;;
      *)
            gprintf "Usage: liveice {start|stop|restart|reload|status}\n"
            exit 1
    esac
    
    exit 0
    

Last modified: Nov 25, 2005 12:48 pm.
Contact me.

Powered by Zope