HOWTO: Hear multiple sounds using both esd and ALSA

(taken from http://www.ubuntuforums.org/printthread.php?t=32063&pp=40)

These are the instructions on enabling software mixing, to avoid application problems like Audacity needing killall esd to work while another application is playing music.

(1) libesd-alsa0 should be installed (it already is in dapper)

(2) We need to create /etc/asound.conf, including the following lines:

pcm.card0 {
  type hw
  card 0
# mmap_emulation true
}

#pcm.dmix0 {
#  type dmix 
#  ipc_key 34521 
#  slave {
#    pcm "card0" 
#  }
#}

pcm.dmix0 {
        type dmix
        ipc_key 1024 ## needs to be a power of 2
        slave {
                pcm "hw:0"
                period_time 0
                period_size 1024
                buffer_size 8192
              # format S16_LE
                rate 44100 ## not necessary
        }
#slowptr true
}

pcm.dsnoop0 {
  type dsnoop 
  ipc_key 2048
  slave {
    pcm "card0" 
  #  rate 48000
  }
}

pcm.asym0 {
  type asym 
  playback.pcm "dmix0" 
  capture.pcm "dsnoop0"
}

pcm.pasym0 {
  type plug 
  slave.pcm "asym0"
}

# 'dsp0' is expected by OSS emulation etc.
pcm.dsp0 {
  type                  plug
  slave.pcm            "asym0"
}

ctl.dsp0 {
    type                hw
    card                0
}

pcm.!default {
  type                  plug
  slave.pcm            "asym0"
}

ctl.!default {
    type                hw
    card                0
}

(3) Also, we need to change /etc/esound/esd.conf contents so:

[esd]

auto_spawn=1

spawn_options=-terminate -nobeeps -as 2 -d default

spawn_wait_ms=100

# default options are used in spawned and non-spawned mode

default_options=

(4) Now we need to change ubuntu sound server to alsa (we can leave it ESD but we better use alsa because it has better sound handling): "gstreamer-properties" -- Change both (in the Audio Tab not the Video) from ESD to ALSA.

(5) All that's left now is to restart computer (after restart you must hear sound) to enable these changes. Also configure XMMS or Beep-media-player (or any player) to use ALSA instead of eSound/ESD. If you hear a strange sound, just change everything back to ESD. If everything worked correctly, now Audacity & Skype will work normally and all the program will play sound using either Alsa or ESD.

Notes

  • If you couldn't play any sounds using ALSA then your /etc/asound.cond & /etc/esound/esd.conf needs some more advanced tweaking (or your sound card just won't support it).

  • if realplayer still doesn't work after switching to alsa, this is because it is looking for /dev/dsp which is the oss device. Fortunately, alsa includes oss emulation. to enable it, just type "modprobe -v snd-pcm-oss"; this will create the /dev/dsp device, routed to alsa. Realplayer (and other oss only apps, no doubt) then works. If that works fine, then just add snd-pcm-oss to the file /etc/modules; it will be loaded automatically at boot.
  • Also you might find sdl games no longer have sound here's a fix: SDL tries to use hw:0, and without intervention, it fails to open audio device. But SDL uses AUDIODEV environment variable, so it placed such file to /etc/profile.d/, example dmix_sdl.sh: "export AUDIODEV=default". Note that for sdl games you should have libsdl1.2debian-alsa installed. You could install the esd version but both will work and this way you can have sdl games work in another window manager where you might not be running esd. It defaulted to libsdl1.2debian-oss. Not sure exactly why that doesn't work when alsa has oss emulation.
  • and finally mplayer can be modified within the gui (gmplayer) but mplayer alone won't read that. Here's my ~/.mplayer/config:
    vo="xv"
    ao="alsa:device=default"
    The vo="xv" will set mplayer to use xv hardware overlay for video so most of you will want that as well if you haven't set it as such. I'm mainly use totem but it's nice to have mplayer working with this setup. And the gstreamer-properties test with this setup will work for both playback and recording.


CategorySoftware

EnableSoftwareMixing (last edited 2011-04-08 15:13:23 by D9784B24)