The Enlightened Sound Daemon (ESD) ---------------------------------- Shanker Balan http://shankerbalan.com/ Changelog: Wed Apr 30 14:01:24 IST 2003 - Initial commit Have you ever wanted to play MP3s and listen to Licq scream 'Incoming Chat Request' at the same time? You do? Cool! Read on! ** What is EsounD? ** Normally, when two or more applications want to play sounds at the same time, it's on a first-come, first-served basis. Whoever gets to the audio device first wins. This is usually the case in Windows and other mainstream OSes (except BeOS). But EsounD changes all of that... The Enlightened Sound Daemon (aka ESD or EsounD) is a sound server designed to mix together several digitized audio streams for playback by a single device. In short, EsounD lets you listen to sound output from a variety of sources like XMMS, GNOME/Enlightenment desktop sound schemes or Licq "OnEvent" sounds, all simultaneously on the same PC using a single sound card. It also has network transparency built in, so you can play sounds on one machine, and listen to them on another. No more will you have to stop XMMS or any other application which is currently using the audio device so that you can listen to another audio source. Interesting eh? Shall we get started? ** How does it work? ** To put it simply, EsounD is a stand-alone sound daemon which abstracts the system sound device to multiple clients. The EsounD daemon connects to the sound device and accepts connections from multiple clients, mixing the incoming audio streams and sending the result to the sound device. EsounD is available for other Unices as well and works quite nicely with both OSS and ALSA sound drivers. ** Installing EsounD ** Install the EsounD RPMS from the PCQlinux 7.1 CD1 if it has not been installed: ~# mount /mnt/cdrom ~# cd /mnt/cdrom/RedHat/RPMS/esound*.rpm Use 'sndconfig' for configuring the sound card. ** Supported Applications ** Some of the more common applications which supports EsounD are: XMMS Mpg123 Enlightenment RealAudio Player GNOME Applications ** Client Setups ** XMMS: XMMS includes the EsounD output plug-in by default. One just needs to enable the plug-in. 1. Start XMMS 2. Open the Options dialog window by pressing CTRL+p hot-key or via the right click menu. 3. Click on the "Audio I/O Plugins" tab. 4. On the bottom, you would see that the output plug-in has been currently set to "OSS Driver 1.2.x [libOSS.so]". Click on the drop-down box and change it to "EsounD Output Plugin 1.2.x [libesdout.so]". 4. Click "Apply" and then "Ok" to make the changes effective. XMMS will now use the EsounD plugin for sound output. Play an MP3 file to check whether it works. Lets verify whether XMMS is using the EsounD plugin by using the 'esdctl' command. Esdctl is a control program for EsounD and is part of the EsounD suite of utilities. You should get an output similar to this which shows that XMMS is using EsounD. ~# esdctl allinfo server version = 0 server format = 0x00000021 server rate = 44100 player 6 name = xmms - plugin <----- player 6 format = 0x00001021 player 6 rate = 44100 player 6 left = 256 player 6 right = 256 The command 'esdctl allinfo' will get the server and sample information from the running EsounD process. 'ps ax|grep esd' should list the esd process currently running. ~# ps ax|grep esd 7018 ? S 0:00 esd -terminate -nobeeps -as 2 -spawnpid 7016 Once the stream has been finished playing, the esd process will automatically exit. Playing Multiple Streams ------------------------ Do you want to play more than one MP3 simultaneously just for kicks? You do? Then, 1. Hit CTRL+P again in XMMS 2. Click on the "Options" tab and enable "Allow multiple instances". 3. Hit "Apply" and then "Ok". 4. Start another copy of XMMS and hit the play button. Let's take a look at the output of 'esdctl allinfo' with 2 streams playing. ~# esdctl allinfo server version = 0 server format = 0x00000021 server rate = 44100 player 6 name = xmms - plugin <- Stream 1 [..] player 8 name = xmms - plugin <- stream 2 [..] You should be hearing 2 songs being played back simultaneously without any problems! If you are like me, you would quickly want to revert back to one MP3 stream ASAP. Mpg123: "mpg123" is a command line based MP33 player. By default, mpg123 uses EsounD for output. ~# mpg123 my_song.mp3 Mpg123 will play the above MP33 using the EsounD plugin. If you try playing another stream using XMMS or mpg123, they will all use EsounD. ~# esdctl allinfo [..] player 7 name = mpg123 Enlightenment Window Manager: 1. Start X windows with e as window manager 2. Right click on the desktop and select "Audio Settings" menu 5. Enable "Sounds in Enlightenment" 6. Hit "Apply" and then "Ok" for changes to take effect. ~# esdctl allinfo [..] sample 1 name = /usr/share/enlightenment/themes/BrushedMetal-Tigert/sound/samples/SOUND_FOCUS_SET.wav Looks like things are working right. Licq: For those applications which do not have builtin support for EsounD, there is a helper application called "esdplay" which one can use. Licq for example, uses an external application called "play" (part of the sox package) to produce sound on events. "play" needs to have direct access to the sound device /dev/dsp and hence will not work with EsounD. For this reason we will be using 'esdplay' which is the "esdified" replacement for 'play' and is part of the EsounD package . 1. Start licq 2. Click Start -> Options to open the licq option window 3. Click on the "OnEvent" tab 4. Enable the "OnEvents" check box 5. Change the Command text box from "play" to "esdplay" 6. Click "Apply" and then "OK" to make the changes effective. Licq is now ready to do the esd dance. RealPlayer: RealNetwork's RealPlayer too includes EsounD support. RealPlayer RPMS for Linux can be downloaded from www.real.com. 1. Start "realplayer" and click "View" -> "Preferences" 2. Click on the "Performance" tab and and choose "EsounD support" in the audio driver options. EsounD over the network ----------------------- Like i mentioned in the beginning, EsounD is network transparent. This means that the client, say XMMS, need not be running on the machine on which esd is running. Double cool eh? Psst... don't let your network administrator catch you in the "act". Suppose you have a situation like this - You have your own workstation with sound support but do all your work on an X Terminal. You usually don't get console ownership and hence no sound (usually). This is a perfect situation to exploit the network transparency features of EsounD. Getting EsounD over the network is not as simple as pointing a client like XMMS to use EsounD. In the single user case, the client will automatically start EsounD. In a networked environment, it does not work that way. The EsounD server has to be started manually before it can receive a sound stream over the network. Server side setup: ----------------- On the machine on which you have sound support, start the EsounD server like this: ~# esd -tcp -public & This command starts the EsounD server on port 16001 (use -p to specify an alternative port number) and makes it accessible over the network (ie, other than localhost) and puts it in the background. You would be able to hear the startup beeps as EsounD goes into to the background. Client side setup ---------------- Client side setup is essentially the same, except that we need to specify the hostname/IP address of the machine and the port on which esd is running. Defining the environment variable "ESPEAKER" is also advisable. ESPEAKER Environment Variable: All applications which have EsounD support (most GTK based applications do) will honor the ESPEAKER value and connect to the EsounD server w/o further help. Other applications like esdplay, esdrec will also use it if the variable has been set. Add this line to your .bash_profile in your home directory on the host from which you would like to "export" sound from: export ESPEAKER=1.2.3.4:16001 Replace "1.2.3.4" with the actual IP address of the host running the Esound server. XMMS: 1. Start XMMS -> Preferences -> Audio I/O Plugins 2. Set the output plugin to "EsounD Output Plugin" 3. Click on the "Configure" button 4. Toggle "Use remote host" to on 5. Set the "Host" and "Port" values as applicable. The hostname should be set to the hostname on which EsounD is running and port to 16001 Hitting the play button would stream the audio from the host on which XMMS is running to the host on which EsounD is running. Licq: Only one minor addition to the esdplay command is to be done here. Change the line "esdplay" in the "OnEvent" dialog box to "esdplay --server=1.2.3.4:16001". This tells esdplay to connect to the EsounD server running on host "1.2.3.4" at port 16001. The general idea in a networked case is to start EsounD on a TCP port 16001 and then point all clients to connect to the machine running EsounD. All of the utils which are a part of the esound suite like esdcat, esdrec, esdmon etc all accept the '--server=' directive and honor the "ESPEAKER" environment available. Mpg123/Enlightenment Mpg123 and Enlightenment will both honor the ESPEAKER environment variable. Stopping EsounD: Once EsounD is started, non esound aware applications will not be able to use the sound device directly. To stop EsounD, run 'killall esd'. Make sure you have closed all applications which are using EsounD before you kill the sound server. #~ killall esd Before we close, i would like to mention that EsounD performance may not be acceptable always. There are times when the audio quality degrades due to system load or network latencies and bandwidth limitations. However, in most circumstances, EsounD does the job. ** Other sound servers ** ASD To overcome the limitations of EsounD, a drop-in replacement called "Advanced Sound Daemon" is being developed. Features include multi-threading and low latency. aRTs The KDE people have adopted aRTs (analog RealRime synthesizer) as their default sound server. KDE2 uses aRTs by default. ** Resources ** The EsounD Homepage: http://www.tux.org/~ricdude/esound.html The RedHat Knowledge-base for EsounD: http://www.redhat.com/knowledgebase/esd/ The aRTs Project: http://www.arts-project.org/ XMMS Homepage: http://www.xmms.org/