From the ALSA wiki
|The FAQs have been reorganized. The new location of this question is FAQ#What are the relationships among devices, subdevices, PCM definitions, channels, and speakers? Does a PCM correspond to a device or a subdevice? To a channel?|
What are the relationships among devices, subdevices, PCM definitions, channels, and speakers? Does a PCM correspond to a device or a subdevice? To a channel?
I'll try to answer this question as well as I can. Please correct me. First take a look at the contents of the file
On my system it looks like this:
0: [0- 0]: ctl 8: [0- 0]: raw midi 18: [0- 2]: digital audio playback 17: [0- 1]: digital audio playback 16: [0- 0]: digital audio playback 24: [0- 0]: digital audio capture 1: : sequencer 33: : timer 32: [1- 0]: ctl 43: [1- 3]: raw midi 42: [1- 2]: raw midi 41: [1- 1]: raw midi 40: [1- 0]: raw midi
This is the list of devices known on the lowest level, the kernel level. I have got one soundcard cs46xx and the virtual MIDI soundcard virmidi loaded. If you look at the first number in the "
[ ]" in the above listing you will see that there are devices
[0- x] and
[1- x]. The 0 and 1 correspond to the card which contains this device. Here's the contents of
0 [CS46xx ]: CS46xx - Sound Fusion CS46xx Sound Fusion CS46xx at 0xcffef000/0xcfe00000, irq 5 1 [VirMIDI ]: VirMIDI - VirMIDI Virtual MIDI Card 1
So we have card 0 and card 1 and each contains some devices as can be seen from the above contents of
/proc/asound/devices. There are different types of devices [digital audio devicess, ctl-devices, midi-devices]. For now, we are only interested in the digital audio devices. It's important to know that applications that use ALSA to play sound usually do not use the kernel modules directly. They rather access the alsa-lib to open PCM-devices. These PCM devices can be either aliases for real hardware devices (digital audio playback and capture devices) on the soundcard or they can be "virtual" devices defined in the plugin layer of alsa-lib.
The user can use a config file
.asoundrc to define new PCM devices and to use some of the plugins provided by alsa-lib to configure them. See the DmixPlugin and LADSPA plugins pages for some uses of this. A typical ALSA-installation has many predefined PCM names like "front", "rear", 'surround", etc.. These are mostly aliases for some of the hardware devices on the soundcard. You can also access the hardware devices through alsa-lib via special names. For example "
hw:0,0" means: the first digital audio device on the first soundcard. "
plughw:1,2" means the third device on the second soundcard but the sample stream is converted to the hardware's native format by alsa-lib first [the "plug" prefix]..
PCM devices can have any number of channels. If it's a hardware PCM device then the channel count is determined by the hardware. Depending on the plugin type (see
.asoundrc a PCM device can have any number of channels. It is for example possible to combine several hardware PCM devices into one virtual PCM device with the help of the multi plugin.
I don't know what subdevices are. Please fill this in.
So as you can see from above, a certain PCM can map to many different hardware devices depending on how it is setup. There's not necessarily a correspondance between audio playback and capture devices and the jacks of the soundcard. Depending on the soundcard and how it is setup via
alsamixer, the capture device can capture different things: line-in, microphone, the output of the soundcard, etc.
The same is true for the playback devices. Depending on your hardware setup, the playback devices can produce output on different jacks of your soundcard. This is especially true with professional-grade multitrack cards that allow sophisticated routing. On consumer grade cards, the ctl device usually only controls whether to send the audio via the digital out or analog, etc.