My requirements are:
- Reading number of channels in playback interface
- Read number of channels in each capture interface
- Mapping WAV channels to specific speakers in/outs
When it comes to speakers it could posssibly be achieved by inspeciting output of alsa-info command:
[ 2.254295] input: HDA Intel PCH Front Mic as /devices/pci0000:00/0000:00:1b.0/sound/card2/input10
[ 2.254441] input: HDA Intel PCH Rear Mic as /devices/pci0000:00/0000:00:1b.0/sound/card2/input11
[ 2.254543] input: HDA Intel PCH Line as /devices/pci0000:00/0000:00:1b.0/sound/card2/input12
[ 2.254726] input: HDA Intel PCH Line Out Front as /devices/pci0000:00/0000:00:1b.0/sound/card2/input13
[ 2.254789] input: HDA Intel PCH Line Out Surround as /devices/pci0000:00/0000:00:1b.0/sound/card2/input14
[ 2.254845] input: HDA Intel PCH Line Out CLFE as /devices/pci0000:00/0000:00:1b.0/sound/card2/input15
[ 2.254904] input: HDA Intel PCH Line Out Side as /devices/pci0000:00/0000:00:1b.0/sound/card2/input16
[ 2.254966] input: HDA Intel PCH Front Headphone as /devices/pci0000:00/0000:00:1b.0/sound/card2/input17
And as I undestand this is mapping between PCI Express and it's names are provided by sound card driver provider. The following outupt could tell about:
- Number of IOs in sound card
- Number of playback IOs (this is by inspecting it's name in search of 'mic')
Is there any way to refer to:
/devices/pci0000:00/0000:00:1b.0/sound/card2/input13
... directly by playing a one channel WAV into it?
Generally I would like to be able to list all sound interfaces and collect parameters that will allow me to play by SDL to any physical speaker and record on particular WAV channel from any physical microphone. I managed to partially achieved this goal by:
- Determine a device that will be used by aplay -l. In my example:
card 0: Device [USB Sound Device], device 0: USB Audio [USB Audio] Subdevices: 0/1 Subdevice #0: subdevice #0
- Determine number of playback capture channels (so far by inspeciting physical device - there is one Line-In and one MIC) However output of
cat /proc/asound/card0/stream0
gives me:
Capture: Status: Stop Interface 2 Altset 1 Format: S16_LE Channels: 2 Endpoint: 5 IN (ASYNC) Rates: 44100, 48000 Bits: 16
So it tells me that I have one capture interface with 2 channels (but I expect 2 captures - one for Line-In and second for stereo Mic)
- So I know that if mic is connected to the interface then I should expect 2 channel WAV and each will correspond to one of Mic channel
Quite simillar story is when it comes to playback interface. Here is cat /proc/asound/card0/stream0
for playback:
Playback:
Status: Running
Interface = 1
Altset = 2
Packet Size = 196
Momentary freq = 48000 Hz (0x30.0000)
Interface 1
Altset 1
Format: S16_LE
Channels: 8
Endpoint: 6 OUT (ADAPTIVE)
Rates: 44100, 48000
Bits: 16
Interface 1
Altset 2
Format: S16_LE
Channels: 2
Endpoint: 6 OUT (ADAPTIVE)
Rates: 44100, 48000
Bits: 16
Interface 1
Altset 3
Format: S16_LE
Channels: 4
Endpoint: 6 OUT (ADAPTIVE)
Rates: 44100, 48000
Bits: 16
Interface 1
Altset 4
Format: S16_LE
Channels: 6
Endpoint: 6 OUT (ADAPTIVE)
Rates: 44100, 48000
Bits: 16
Interface 1
Altset 5
Format: S16_LE
Channels: 2
Endpoint: 6 OUT (ADAPTIVE)
Rates: 96000
Bits: 16
I that case I have physical connectors input for 7.1 speaker setup + headphones. So I expect to have controll over 10 channels but I have over 8 (headphones are allways duplicated as if there was 2.1) Is there any way to access seperately to theese channels? There is also an SPDIF input/output physical interface. Should I expect to have duplicated PCMs on each physical interface allways or there is any way to separate theese streams? I'd like to sqeeze from this sound cars as much I/O as I can :)