Matrix:Module-cs4281

From AlsaProject
Jump to: navigation, search

Enabling Software Mixing for Cirrus Logic CS4281

(I'm not a Linux Guru so this guide is to be used at own risk. It worked for me. Tested on Ubuntu 7.04)

Since this card doesnot support Hardware Mixing under ALSA, you need to allow "Software Mixing". Software Mixing is the ability to play multiple sound files or applications at the same time through the same device.

dmix

These days we have a native plugin for ALSA called the dmix (direct mixing) plugin. It allows software mixing in an easy to use syntax and without the hassle of installing/understanding a new application first.

A very interesting and potentially extremely useful aspect of this plugin is using it combined with the default plugin name. In theory this means all applications that have native ALSA support will share the sound device. In practice not many applications are able to take advantage of this functionality yet. However if you have time to test and report your findings to the application developers it is worth a try:

But first you need to know a bit about the file where we will store dmix configuration.

The .asoundrc file

This file allows the you to have more advanced control over your card/device. The .asoundrc file consists of definitions of the various cards available in your system. It also gives you access to the pcm plugins in alsa-lib. These allow you to do tricky things like combine your cards into one or access multiple i/o's on your mulitchannel card.

Neither the .asoundrc nor the asound.conf files are required for ALSA to work properly. Most applications will work without them. They are used to allow extra functionality, such as routing and sample-rate conversion, through the alsa-lib layer.

Where does asoundrc live?

The asoundrc file is typically installed in a user's home directory

$HOME/.asoundrc

and is called from

/usr/share/alsa/alsa.conf

It is also possible to install a system wide configuration file as

/etc/asound.conf

When an alsa application starts both configuration files are read.

Enabling Software Mixing:

Make a file called .asoundrc in your home and/or root directory.

       vi /home/xxx/.asoundrc

copy and paste the following into the file then save it.

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

 
    pcm.dmixer  {
	type dmix
	ipc_key 1024
	slave {
	    pcm "hw:0,0"
	    period_time 0
	    period_size 1024
	    buffer_size 4096
	    rate 44100
	}
	bindings {
	    0 0
	    1 1
	}
    }
 
    ctl.dmixer {
	type hw
	card 0
    }


Now try:

aplay -f cd -D default test.wav

on multiple consoles.

Some notes:

The dmix PCM name is already defined in the global configuration file /usr/share/alsa/alsa.conf.

- The default sample rate for this device is 48000Hz. If you would like to change it use:

	aplay -D"plug:'dmix:RATE=44100'" test.wav

- An example command for dmix plugin to use 44100Hz sample-rate and hw:1,0 output device:

	aplay -Dplug:\'dmix:SLAVE=\"hw:1,0\",RATE=44100\' test.wav

- The dmix PCM name is already defined in the global configuration file /usr/share/alsa/alsa.conf.

Defaults are:

SLAVE="hw:0,0",RATE=48000

NB the dmix plugin is not based on client/server architecture, but it writes directly to the soundcard's DMA buffer. There is no limit to the amount of instances that can be run at one time .

Saad Bin Javed

Jul 2, 2007

Custom Search
Personal tools
Namespaces

Variants
Actions
Navigation
wiki
Toolbox