[LAD] a little help with mutichannel alsa

Paul Davis paul at linuxaudiosystems.com
Sun Oct 7 22:40:17 UTC 2012

On Sun, Oct 7, 2012 at 4:03 PM, <grekimj at acousticrefuge.com> wrote:

> First, what I would like to do is pick which channel I send audio to on
> the RME 9632 card.
> My RME card is device 0.
> When I call this function:
> snd_pcm_open(&handle,device,SND_PCM_STREAM_PLAYBACK,0)
> And set device = plughw:0,0   I get playback across all the RME outputs.
> (Just using hw:0,0  without the "plug" prefix does not work for some
> reason which may or may not matter.)

with ALSA, devices named "hw:..." can only be configured in ways that match
the hardware capabilities of the device. no configuration that requires the
driver or libasound to resample, reformat etc. etc. are allowed. note that
this includes the number of channels, so if the h/w has N channels you
cannot configure it for anything other than N channels.

"plughw:..." devices are much more flexible and will use the full
capabilities (such as they are) of the driver and libasound to provide a
much broader configuration space.

> So, how do I access the subdevices/channels?
> When I run aplay -l I only see 1/1 subdevices.
> Shouldn't I be able to set my device to hw:0,0,1 or plughw:0,0,1 to access
> channel 2, for example?

multichannel devices are multichannel devices. you don't open a different
device to get to different channels. you open it, and get a device with as
many channels as you specified. they will start at physical channel zero,
unless you use a psuedo-device (typically defined via an ~/.asoundrc file)
that maps physical channels to channels in the pseudo-device.

the way in which you access each channel depends on the configuration
parameters you use with the device. all the code i write uses
non-interleaved format, so that each channel's samples consist of a
contiguous block. some people prefer interleaved.

if you are just trying to write a functioning application rather than learn
to use ALSA, you will find it MUCH MUCH easier to just use JACK. if you
want to learn ALSA, be prepared to do a lot of reading of (a) the rather
non-explanatory reference documentation (b) finding examples of other
source code that uses ALSA in this way (e.g. JACK).

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-dev/attachments/20121007/d61ca362/attachment.html>

More information about the Linux-audio-dev mailing list