ALSA Configuration: Difference between revisions

From Elvanör's Technical Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 6: Line 6:


* After that, you need to get dmix working, both for ALSA and for OSS (through ALSA emulation). dmix is a plugin to get software sound mixing. Follow this [http://gentoo-wiki.com/HOWTO_ALSA_Complete_%28includes_dmix%29 guide on the Gentoo Wiki.] Be careful so that you get dmix working correctly with OSS, else some important applications using OSS (Firefox) won't work properly with ALSA applications (Amarok). On AMD64, make sure the 32-bits ALSA emulation libraries are new enough (last section of the wiki).
* After that, you need to get dmix working, both for ALSA and for OSS (through ALSA emulation). dmix is a plugin to get software sound mixing. Follow this [http://gentoo-wiki.com/HOWTO_ALSA_Complete_%28includes_dmix%29 guide on the Gentoo Wiki.] Be careful so that you get dmix working correctly with OSS, else some important applications using OSS (Firefox) won't work properly with ALSA applications (Amarok). On AMD64, make sure the 32-bits ALSA emulation libraries are new enough (last section of the wiki).
* Note that since version 9, Flash Player uses ALSA. There is no more reason to setup Firefox to use OSS. By the way, Firefox by itself does not know at all about sound.


* To get audio recording working correctly, you need to unmute levels correctly in alsamixer. You also need to choose the correct input sources. In alsamixer, type '''tab''' to get to the capture PCMs, else you don't see them in the basic view. Make sure everything is setup correctly and unmuted. You can then test if your microphone is correctly working by running the command:
* To get audio recording working correctly, you need to unmute levels correctly in alsamixer. You also need to choose the correct input sources. In alsamixer, type '''tab''' to get to the capture PCMs, else you don't see them in the basic view. Make sure everything is setup correctly and unmuted. You can then test if your microphone is correctly working by running the command:

Revision as of 13:00, 9 November 2007

ALSA (Advanced Linux Sound Architecture) is the new Linux sound system, replacing the deprecated OSS. Alsa offers advanced features such as software mixing for audio cards that don't support hardware mixing. It is thus important to get it properly working.

Guide to ALSA installation and configuration

  • The first step is to follow the official Gentoo ALSA guide to get ALSA basically installed and working. The ALSA sources are now included in the kernel, which is very nice.
  • After that, you need to get dmix working, both for ALSA and for OSS (through ALSA emulation). dmix is a plugin to get software sound mixing. Follow this guide on the Gentoo Wiki. Be careful so that you get dmix working correctly with OSS, else some important applications using OSS (Firefox) won't work properly with ALSA applications (Amarok). On AMD64, make sure the 32-bits ALSA emulation libraries are new enough (last section of the wiki).
  • Note that since version 9, Flash Player uses ALSA. There is no more reason to setup Firefox to use OSS. By the way, Firefox by itself does not know at all about sound.
  • To get audio recording working correctly, you need to unmute levels correctly in alsamixer. You also need to choose the correct input sources. In alsamixer, type tab to get to the capture PCMs, else you don't see them in the basic view. Make sure everything is setup correctly and unmuted. You can then test if your microphone is correctly working by running the command:
arecord -f cd -d 2 -t wav -N test.wav
  • IMPORTANT: you need to set to "Capture" your correct source. This means the word CAPTURE in red should appear below, not "----". To toggle the capture status, hit the space bar. If you don't do that, the mic will be unmuted but the computer won't capture/record the sound.
  • If you use dmix, to record correctly you need to setup the asym plugin and the dsnoop plugin. dsnoop is for input what dmix is for output, eg it should mix several input sources into one. I don't think it is as useful as dmix (the really important thing is to have the asym plugin setup), however I've configured it on my system. For Skype to work with dsnoop you need to add some magic values to your /etc/asound.conf file, as shown below.
  • My sample asound.conf file:
# etc/asound.conf:

# We route OSS through dmix

pcm.dsp0 {
    type plug
    slave.pcm "duplex"
}

ctl.dsp0 {
     type plug
     slave.pcm "duplex"
}

# This is just an alias for hw:0,0

pcm.sound_card {
     type hw
     card 0
     device 0
}

# We route everything through the asym plugin by default

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

pcm.duplex {
        type asym
                capture.pcm "input"
                playback.pcm "output"
}

# Dmix plugin

pcm.output {
     type dmix
     ipc_key 1024
     slave.pcm "sound_card"

     slave {
          # This stuff provides some fixes for latency issues.
          # buffer_size should be set for your audio chipset.
          period_time 0
          period_size 1024
          buffer_size 8192
     }

     bindings {
          0 0
          1 1
     }
}

# Dsnoop plugin

pcm.input {
        type dsnoop
                ipc_key 1133
                #slave.pcm "sound_card"
                slave {
      # "Magic" buffer values to get Skype audio to work
      # If these are not set, Skype recording (microphone) WILL NOT WORK.
                pcm "sound_card"
                period_size 256
                periods 16
                buffer_size 16384
                }
        bindings {
        0 0
        1 1
        }
}
  • For Wine to work correctly with ALSA, you apparently need to change some sections, reproduced below:
ctl.!default {
        @args [ CARD ]
        @args.CARD {
                type integer
                default 0
        }

        type hw
        card $CARD
}

pcm.!default {
        @args [ CARD DEVICE ]
        @args.CARD {
                type integer
                default 0
        }
        @args.DEVICE {
                type integer
                default 0
        }
        type plug
        slave.pcm "duplex"
}

Note that it is very important that the ctl.!default has only the CARD argument, and that the pcm.!default has both CARD and DEVICE.

ALSA Input Sources

They are located at the end of the playback view. Be sure that the Input Source (the first one) is set to whatever you need. You can switch sources by pressing the 'w' or 'x' keys.

Recent drivers

  • For recent ALSA drivers (1.0.14/1.0.15), everything seems to work better "by default". dmix is activated, Skype and OSS apps just work without any configuration.