1

I am writing code on Raspberry Pi that connects to a ICUSBAUDIO7D device for capture. I have been successful so far talking when I pass in "default" as a path

r = snd_pcm_open(&_pcm, "default",
                          SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK);
 

and I able to capture the audio,

I have defined in /usr/share/alsa/alsa.conf

defaults.ctl.card 1
defaults.pcm.card 1

but what I would like to do is be able to select input from Line or Mic.
looking at amixer I see that

Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right - Rear Left - Rear Right - Front Center - Woofer - Side Left - Side Right
  Limits: Playback 0 - 197
  Mono:
  Front Left: Playback 0 [0%] [-36.93dB] [on]
  Front Right: Playback 0 [0%] [-36.93dB] [on]
  Rear Left: Playback 90 [46%] [-20.06dB] [on]
  Rear Right: Playback 90 [46%] [-20.06dB] [on]
  Front Center: Playback 90 [46%] [-20.06dB] [on]
  Woofer: Playback 90 [46%] [-20.06dB] [on]
  Side Left: Playback 0 [0%] [-36.93dB] [on]
  Side Right: Playback 0 [0%] [-36.93dB] [on]
Simple mixer control 'PCM',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 6928
  Front Left: Capture 4096 [59%] [-0.01dB] [on]
  Front Right: Capture 4096 [59%] [-0.01dB] [on]
Simple mixer control 'PCM Capture Source',0
  Capabilities: enum
  Items: 'Mic' 'Line' 'IEC958 In' 'Mixer'
  Item0: 'Line'
Simple mixer control 'Line',0
  Capabilities: pvolume cvolume pswitch pswitch-joined cswitch cswitch-joined
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: Playback 0 - 8065 Capture 0 - 6928
  Front Left: Playback 8065 [100%] [7.50dB] [off] Capture 4096 [59%] [-0.01dB] [on]
  Front Right: Playback 8065 [100%] [7.50dB] [off] Capture 4096 [59%] [-0.01dB] [on]
Simple mixer control 'Mic',0
  Capabilities: pvolume cvolume pswitch pswitch-joined cswitch cswitch-joined
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: Playback 0 - 8065 Capture 0 - 6928
  Front Left: Playback 6144 [76%] [-0.01dB] [off] Capture 4096 [59%] [-0.01dB] [on]
  Front Right: Playback 6144 [76%] [-0.01dB] [off] Capture 4096 [59%] [-0.01dB] [on]
Simple mixer control 'IEC958 In',0
  Capabilities: cswitch cswitch-joined
  Capture channels: Mono
  Mono: Capture [on]

but when I do

arecord -L
null
    Discard all samples (playback) or generate zero samples (capture)
default
    Default Audio Device
sysdefault
    Default Audio Device
duplicate
hw:CARD=ICUSBAUDIO7D,DEV=0
    ICUSBAUDIO7D, USB Audio
    Direct hardware device without any conversions
plughw:CARD=ICUSBAUDIO7D,DEV=0
    ICUSBAUDIO7D, USB Audio
    Hardware device with all software conversions
default:CARD=ICUSBAUDIO7D
    ICUSBAUDIO7D, USB Audio
    Default Audio Device
sysdefault:CARD=ICUSBAUDIO7D
    ICUSBAUDIO7D, USB Audio
    Default Audio Device
front:CARD=ICUSBAUDIO7D,DEV=0
    ICUSBAUDIO7D, USB Audio
    Front output / input
dsnoop:CARD=ICUSBAUDIO7D,DEV=0
    ICUSBAUDIO7D, USB Audio
    Direct sample snooping device
amixer -c 1 scontrols
Simple mixer control 'Speaker',0
Simple mixer control 'PCM',0
Simple mixer control 'PCM Capture Source',0
Simple mixer control 'Line',0
Simple mixer control 'Mic',0
Simple mixer control 'IEC958 In',0

I dont really see Mic or Line as a device.. so I am confused here how do I programmatically select one or the other?

can someone offer me a clue? many thanks.

Marcus Müller
  • 21,602
  • 2
  • 39
  • 54

0 Answers0