This document explains how to make and manage one or more Internet radio feeds using [[http://musicpd.org][MusicPD]] and [[http://www.icecast.org/][Icecast]] 2. * Install the packages If you're using Ubuntu, you will want the =mpd=, =mpc=, and =icecast2= packages, along with their dependencies. I recommend using MusicPD version 0.13.0 or greater, because several important shoutcast-related bugs were fixed in that release. * Icecast settings Now I will provide sample configurations files for each part of the setup. Here's my =/etc/icecast2/icecast.xml= file, with commented-out items removed and passwords scrubbed. 100 10 5 524288 60 30 20 1 65535 password_1 password_2 admin password_3 15 http://dir.xiph.org/cgi-bin/yp-cgi music.purduelug.org 8000 1 /usr/share/icecast2 /var/log/icecast2 /usr/share/icecast2/web /usr/share/icecast2/admin access.log error.log 2 10000 0 * MusicPD settings Here's a MusicPD configuration file that I placed in =~/.mpd/8bitpeoples.conf=. There are 2 more of them, similarly configured, each using a different control port (6600 - 6602). Again, commented out parts are removed and passwords have been scrubbed. # MPD CONFIG FILE # For a full description of all config parameters, # Check the mpd man page, "man mpd". ##################### REQUIRED ########################### music_directory "/home/mwolson/music/" playlist_directory "/home/mwolson/playlists" db_file "~/.mpd/mpd.db" log_file "~/.mpd/8bitpeoples.log" error_file "~/.mpd/8bitpeoples.error" pid_file "~/.mpd/8bitpeoples.pid" state_file "~/.mpd/8bitpeoples.state" ########################################################## # # Hack to make MPD work properly, with no audio being sent to the # system: # audio_output { type "ao" driver "null" name "Dummy output" } # # An example of a shout output (for streaming to Icecast): # audio_output { type "shout" name "8bitpeoples" host "127.0.0.1" port "8000" mount "/8bitpeoples.ogg" password "password_1" quality "5.0" # bitrate "128" format "44100:16:1" user "source" description "http://www.8bitpeoples.com/ -- Retro electronica" genre "Electronica" } # end of audio_output # Software Mixer mixer_type "software" ################# REPLAYGAIN ############################# # # Use Replay Gain (album or track) # http://www.replaygain.org # replaygain "track" # # Sets the pre-amp used for files that have replaygain # info. Valid values are between -15 to 15 (in dB). # #replaygain_preamp "0" # ########################################################## # Set this value if you only have one # address you want to allow connection to. # bind_to_address "127.0.0.1" port "6601" # This sets the metadata mpd will use, to disable all metadata, set to "none" # NOTE: comments are disabled by default # metadata_to_use "artist,album,title,genre,date,track,composer,performer,comment" * Control scripts ** start-radio This is a script that is used to restart all of the radio stations. #!/bin/sh # # Usage: start-radio # # Assumes that MusicPD settings are in the .mpd directory, and that # music is located in the $STATION directory, where $STATION # corresponds with the names of the available stations. PORT=6600 for i in OCR 8bitpeoples FSF; do echo "Starting $i feed ..." mpd .mpd/$i.conf sleep 1 export MPD_PORT=$PORT export MPD_HOST=localhost mpc stop echo "Updating database ..." mpc update $i sleep 5 mpc clear > /dev/null echo "Adding songs ..." mpc search filename "$i/" | mpc add > /dev/null mpc random on > /dev/null mpc repeat on > /dev/null mpc play PORT=`expr $PORT + 1` done echo "Done." ** restart-station Here's a script that can be used to restart one particular station, if it needs to have new songs added to its lineup. #!/bin/sh # # Usage: restart-station # # Assumes that MusicPD settings are in the .mpd directory, and that # music is located in the $STATION directory, where $STATION # corresponds with the names of the available stations. case "$1" in OCR ) port=6600 ;; 8bitpeoples ) port=6601 ;; FSF ) port=6602 ;; * ) echo "Usage: restart-station " echo "Available stations: OCR 8bitpeoples FSF OpenMusic" exit 1 ;; esac echo "Restarting $1 station ..." # kill station PID=`cat .mpd/$1.pid 2>/dev/null` [ -n "$PID" ] && kill $PID # bring station back up mpd .mpd/$1.conf sleep 1 export MPD_PORT=$port export MPD_HOST=localhost # update song database echo "Updating database ..." mpc update $1 sleep 5 mpc clear > /dev/null # add songs echo "Adding songs ..." mpc search filename "$1/" | mpc add > /dev/null mpc random on >/dev/null mpc repeat on >/dev/null mpc play echo "Done." * Going further: a request tracker It would be neat to see a request tracker that works with MusicPD, so that listeners can choose a song that they want to hear next. I really liked that feature when listening to VGamp (=http://vgamp.com=). It ought to be reasonably easy to implement, even the parts that prevent abuse. It looks like [[https://ampache.bountysource.com/][Ampache]] might be able to do this, along with its [[https://ampache.bountysource.com/wiki/Features/Icecast2][Democratic Play]] functionality. I haven't checked it out yet.