ALSA samples capture: cannot open device
- by Randagio
I'm quite new to Linux (Lubuntu 12.04 for sake of precision) and ALSA programming at all.
I'm trying to write a C program to capture audio from internal PC microphone for processing it.
So as first step I google a bit and I found this article for capturing audio samples
A tutorial on using the ALSA Audio API
but when I compile it and execute it with:
./capture "default" or ./capture "hw:0,0" and all the possible variants on theme it always raises the error:
cannot open device hw:0,0 (no such file or directory).
So the issue is: what is the name of the mic audio device to pass as parameter to record the audio from mic ?
The mic is working ok because the Sound Recorder program records sounds perfectly and I can playback them.
The output of the aplay -l is the following :
**** List of PLAYBACK Hardware Devices ****
card 0: I82801DBICH4 [Intel 82801DB-ICH4], device 0: Intel ICH [Intel 82801DB-ICH4]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: I82801DBICH4 [Intel 82801DB-ICH4], device 4: Intel ICH - IEC958 [Intel 82801DB-ICH4 - IEC958]
Subdevices: 1/1
Subdevice #0: subdevice #0
and this is the amixer output (cut)
Simple mixer control 'Master',0
Capabilities: pvolume pswitch penum
Playback channels: Front Left - Front Right
Limits: Playback 0 - 31
Mono:
Front Left: Playback 31 [100%] [0.00dB] [on]
Front Right: Playback 31 [100%] [0.00dB] [on]
Simple mixer control 'Master Mono',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined penum
Playback channels: Mono
Limits: Playback 0 - 31
Mono: Playback 4 [13%] [-40.50dB] [on]
Simple mixer control 'PCM',0
Capabilities: pvolume pswitch penum
Playback channels: Front Left - Front Right
Limits: Playback 0 - 31
Mono:
Front Left: Playback 31 [100%] [12.00dB] [on]
Front Right: Playback 31 [100%] [12.00dB] [on]
Simple mixer control 'CD',0
Capabilities: pvolume pswitch cswitch cswitch-exclusive penum
Capture exclusive group: 0
Playback channels: Front Left - Front Right
Capture channels: Front Left - Front Right
Limits: Playback 0 - 31
Front Left: Playback 0 [0%] [-34.50dB] [off] Capture [off]
Front Right: Playback 0 [0%] [-34.50dB] [off] Capture [off]
Simple mixer control 'Mic',0
Capabilities: pvolume pvolume-joined pswitch pswitch-joined cswitch cswitch-exclusive penum
Capture exclusive group: 0
Playback channels: Mono
Capture channels: Front Left - Front Right
Limits: Playback 0 - 31
Mono: Playback 22 [71%] [-1.50dB] [on]
Front Left: Capture [on]
Front Right: Capture [on]
Simple mixer control 'Mic Boost (+20dB)',0
Capabilities: pswitch pswitch-joined penum
Playback channels: Mono
Mono: Playback [off]
Simple mixer control 'Mic Select',0
Capabilities: enum
Items: 'Mic1' 'Mic2'
Item0: 'Mic1'
Simple mixer control 'Stereo Mic',0
Capabilities: pswitch pswitch-joined penum
Playback channels: Mono
Mono: Playback [off]
so for aplay it seems I have no recording device, but for amixer I've got the mic, a mic boost and mic stereo as well with all those gorgeous stuffs on their place !!.
If so, how could my Sound Recorder record the audio without any problem at all ?!?!
For sure I'm giving the wrong device name to the command line for capturing audio but I'm loosing the hope for finding the correct one !
Please help....before I tear my hair out !!!