Sunday, November 2, 2014

Understanding ALSA device, subdevice and cards.

ALSA calls each audio controller a 'card'; each card has 'devices'; a device is something which's capable of either processing an audio stream (for playback) or sending an audio stream (capture).

ALSA gives these cards and devices numbers starting from 0.

There are also subdevices which are a part of an input or output device. There must be at least 1 subdevice. In context of output devices, a device having multiple subdevices means the hardware can do mixing, i.e. it can take multiple streams of PCM and mix them to produce a single output. This's called hardware mixing and no, multichannel is a different thing. The no. of streams a device can take depends on the no. of sub devices a device has. Using ALSA API, you can send audio to each of these subdevices simultaneously; the result will be seen in the output audio.

Subdevice in capturing means the card can take and digitize input of multiple audio streams at once.
Usually subdevice have 'modes' in which they operate. For output subdevices, it means the multichannel mode they operate in. Like 2 or 4 or 6 or 7 etc... which's activate other multichannel ports on the sound card.

For input subdevice it means from which port will the input be taken from (like line in, mic, front mic etc...)

There's a ncurses based mixer which alsa provides name alsamixer... change your volumes from there. You may use amixer which you can use to change volume levels via command.

Here you can set your base and treble settings also (it might be present depending on your sound card). Press m for mute/unmute.

In the playback section, can set the mode the soundcard is (same as subdevice mode). Options will be 2ch, 4ch, 5ch etc... Also you'll be also to select the output levels of multiple speakers in the multichannel setup. In stereo mode (2ch) the front speaker levels specify the volume of the 2 channels.

In the playback section you might also see mixers which specify input device... here it will stream the input from that device to the output device. In the same playback section and in some devices you will be able to set the mode of the recording for the input jack on your sound card (line in or mic in).

In case there's a lot of disturbance in the output audio, turn off a few reluctant channels.

Again depending on the audio device, you might be able to configure the output of the digital SPDIF interface, this interface has it's own separate PCM. S/PDIF will also contain an optional called S/PDIF Playback Source... here you gotta set from where will the audio be streamed from.

In the capture section, you'll find 'mux' which acts as a sort of amplification to the input.

You'll see a no. of 'input source'; each mark an input subdevice. You may change their value to mark an input port like mic, front mic, line in etc...

The various capture channels set the volume for the various input source.

ALSA maintains a table of possible sample rate and sampling formats the device takes. Not all possible combinations can be taken in by the card.

ALSA provides plugins via which you can access the device; a device has to be named this way –

Unlike with OSS where you can send raw PCM directly to a device which was spawned in /dev, with alsa, these devices are still there but sending streams to them is not that simple and controlling them is a different challenge. These ALSA devices are present in /dev/snd. Control* mark control of the device/subdevice and pcm* mark the device to which PCM has to be sent or PCM has to be received from. Alsa-lib is a set of libraries which make the task easy. These plugins are provided by alsa-lib.

Some sample plugins –

hw – for raw device access for both playback and recording. The stream sent to the device should be something accepted by the sound card (suitable format/sample rate).

plughw – This's transparent conversions between various wave sample format and sample rate to something which can be accepted by the sound card.

You may omit one or both of ,. ALSA will be on it's instincts to select one.
The plugin with the hardware is also called the device. Thus “:,,” will also be called a device.

Some plugins take in these devices (i.e. plugin in a plugin) e.g. –

tee:\'hw:0,0\',\'hw:0,3\',raw pro_logic_ii_the_other_side_44khz.wav

The tee plugin which'll work like tee – stream to 2 device off which one device may or may not be a file. raw pro_logic_ii_the_other_side_44khz.wav is the input file.

Similarly there's a file plugin.

No comments:

Post a Comment