How to be a source for a shoutcast server from within the Linux OS. Guide written by Andrew Humphries on 23/03/2003. Stuff needed ------------ 1) Xmms (should include song-change plugin) (http://www.xmms.org) 2) Darkice streaming software (http://darkice.sf.net/) 3) shoutcast-titles.sh script (here) 4) Server name, port and password for the shoutcast server you connect to 5) Soundcard mixer software (e.g. kmix) for controling sound levels 6) Lame mp3 encoding libraries (http://sourceforge.net/projects/lame) Set-up ------ 1) Darkice and Lame encoder The included example darkice.cfg is designed to connect to a shoutcast server using a bitrate of 112kbit/s. Feel free to change that if you want. Darkice can be configured to provide streams to multiple servers, and server types. Look at the documentation for darkice for more information. ('man darkice.cfg') Before compiling/using darkice, make sure you have recent Lame (mp3 encoding) libraries installed on your machine, or you won't be able to make an mp3 stream to send anywhere. One important point that I didn't feel was expressed properly in the darkice instructions was the 'port' parameter. You may have been given instructions to connect to e.g. port 8000 - in darkice.cfg however, use 8001. This is probably due to shoutcast using multiple ports. If you want to record to a local mp3 of what exactly you sent to the shoutcast server, use the localDumpFile parameter. In the included example, I have included another output "[file-0]" - this takes the same sound input, and encodes it using a separate thread to a configured mp3 file. Again, look at the darkice docs for more info. Darkice should really be run as the root user so that it can give itself realtime processing priority. I recommend that after you have installed the darkice binary (probably in /usr/local/bin), you run chmod +s /path/to/darkice as root so that you can run darkice as a normal user, but allowing it to run as it were root. You may also want to specify that only one user can run darkice too. BE AWARE that running anything as root user can be insecure - root has system level access, so anything that can potentially hijack a root process can cause system level (bad) problems. 2) Soundcard Mixer Included in are the settings I use to stream. If you have a different soundcard to me, you may have to fiddle... Important note 1: Darkice records whatever source is set as the recording source for the device selected (usually /dev/dsp). This means that you can record the sound card's output if it has a "What-u-hear" source or similar. This allows you to mix a microphone, or use line-in for a vinyl source, etc. Important note 2: The levels I have set on my system are adequate for me, but if you have different hardware (e.g. a more/less sensitive mic), you'll have to change them. Darkice can bet setup to just record to an mp3 file, so I suggest you try that, and compare the levels with a known audio source (e.g. a ripped mp3), before casting. A few other notes: On my setup, "Pcm" is the volume level of generated audio from xmms and any other audio playback programs. "IGain" on my system is apparently the same as "What-u-hear" - i.e. the USEFUL recording source. "OGain" plays back the result of "IGain" through, on my machine, the line-out socket. The "Volume" level is the usual headphone/amp/stereo output of the soundcard. Note that I have the Microphone level MUCH higher than the Pcm level - this lets your voice be heard of the music you're playing. Kmix layout: The green circles at the top of the window indicate whether a source/output is muted. I recommend you mute ALL sources/outputs that you're not intending to use - they'll just add unwanted noise otherwise. (Light green means active, and dark green means inactive) The red circles at the bottom of the window allow you to select the input source - in this case, IGain ("What-u-hear"). You can also setup Kmix to have keyboard shortcuts, which in my opinion are more useful than dragging the sliders up/down with a mouse. (right-click on a source/output, and click "define keys"). This will let you fade the mic up/down or mute it with minimal fuss. I have keys setup for mic up/down/mute and pcm up/down. 3) Xmms Xmms is a great linux audio player, with useful keyboard shortcuts for audio-control, and track selection/changing. While the built-in mp3 decoder is adequate for playing back mp3s, there is another plugin, based on the MAD decoding engine that can be said to produce better output. (more info at http://sourceforge.net/projects/xmms-mad and http://www.underbit.com/products/mad/) My idea is that as the audio is going to be re-compressed anyway, you may as well produce the best quality audio from your system as you can. The most likely scenario for casting may be that you have a playlist of mp3s, wavs, oggs, etc in xmms. Sending the track titles to the server is very useful way of letting your listeners know what you're playing. Unfortunately Darkice DOESN'T know this - its just encodes the soundcard output. To send track titles, you need to send them separately. Xmms on my system (Mandrake 9.0) came with the "Song-Change" plugin (on the "Effect/General Plugins" page in xmms config). This is an ideal method to trigger a program to do something when a track changes, and when a track changes is the ideal time to tell people. Therefore configure song-change to run the following command: /path/to/shoutcast-titles.sh "%s" obviously replacing /path/to with the location you put the script. Whenever the script is run, xmms will replace %s with the track title, and shoutcast-titles.sh will update the server. Currently, the script produces some debugging/informational output, so you may only want to enable the song-change plugin prior to casting, and de-activate it when you've finished. Xmms output plugin: I recommend that you tell xmms to output directly to the soundcard, using OSS, thus bypassing any other sound-processing outputs available which may reduce audio-quality or your ability to mix volume levels properly. Also, you may wish to consider using a crossfade plugin which can be setup to output to OSS very easily. The plugin I use (xmms-crossfade) is very configurable. look for it at http://www.xmms.org/plugins.html or http://www.mynetcologne.de/~nc-eisenlpe2/xmms-crossfade/download.html 4) shoutcast-titles.sh script The idea of this script is to check if darkice is actually running, and if it is, send the track title that was given on the command line (the %s from xmms-song-change) to the shoutcast server specified by editing the configuration section of the script. Make sure the port number used is 1 LESS than the one specified in darkice.cfg, i.e. the port number you were probably actually given. This script will ONLY normally be run when the track title CHANGES in xmms. Therefore, if you are playing a track in xmms, then connect to your shoutcast server, the track title will not be sent. One trick I use is to play a short trailer track immediately when I connect. Also, if you play audio from another source than xmms during your broadcast, the script won't know. The script can of course be launched manually at any time, if you wish to over-ride the track title. Just use a command like this: /path/to/shoutcast-titles.sh "your title here" Making sure you put double-quotes around your intented title. All together now ---------------- Once all that's setup, you now have to coordinate it all during a broadcast. I'll just outline the main (pre-broadcast) steps below: 1) Create a playlist in xmms. 2) Make sure of your darkice and shoutcast-titles.sh configurations. 3) Enable the song-change plugin. 4) Check mixer levels and sources are ok 5) Disable network services/activity that can interfere with your connection 6) Have xmms paused or stopped on a 'trailer' file before running this useful command which will start xmms playing and connect darkice: (sleep 2s;xmms -p)& darkice -v 10 -c darkice.cfg "sleep 2s" delays xmms from playing for 2 seconds while darkice starts recording, and connects to the shoutcast server. "xmms -p" is an xmms command that will tell the running xmms to start playing. "-v 10" tells darkice to be verbose - it will tell you its encoding settings, and any network errors along the way. "-c darkice.cfg" tells darkice which config file to use. 7) During the broadcast you can use xmms just as you normally would, for example to drag and drop tracks, add/remove tracks, change track order, pause, skip, ... I also recommend you keep a sound mixer (e.g. kmix) open so you can adjust volumes for the chatty-bits. (...with shortcut keys) 8) When you're ready to disconnect, press ctrl-C in the terminal window where you started darkice from. You may also want to disable song-change too.