LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 07-14-2010, 06:57 AM   #1
puneeth bhat
Member
 
Registered: Jan 2010
Posts: 30

Rep: Reputation: 15
Audio programming


Can i find sample program to record audio through microphone connected to PC........Any link which would help me......Thanks in advance
 
Old 07-14-2010, 07:46 AM   #2
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
If you will use ALSA, the following might help (from Google: alsa tutorial)

http://www.equalarea.com/paul/alsa-audio.html#captureex

Which sound system do you plan to use?

Last edited by irmin; 07-14-2010 at 07:48 AM.
 
Old 07-14-2010, 09:23 AM   #3
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 2,756

Rep: Reputation: 767Reputation: 767Reputation: 767Reputation: 767Reputation: 767Reputation: 767Reputation: 767
I'd think Audacity would be a fine sample program.

Build it with debugging symbols and then step through the code as you have it record through the microphone.

Last edited by dugan; 07-14-2010 at 09:35 AM.
 
Old 07-15-2010, 02:14 AM   #4
puneeth bhat
Member
 
Registered: Jan 2010
Posts: 30

Original Poster
Rep: Reputation: 15
Audio programming

I have gone through the above link and compiled the program successfully with -lasound....but while executing it with argument /dev/audio i m getting the error as below
ALSA lib pcm.c:2184snd_pcm_open_noupdate) Unknown PCM /dev/audio
cannot open audio device (No such file or directory)

So what changes i have to do.....i have done alsoconf.....no problem with the sound card as i have seen,i have played some .wav files...
Thanks in advance kindly please help.
 
Old 07-15-2010, 05:12 AM   #5
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
The argument you pass to the program is the name of the PCM: e.g. default, hw:0.0 or similar, not an OSS audio device.
 
Old 07-15-2010, 05:25 AM   #6
puneeth bhat
Member
 
Registered: Jan 2010
Posts: 30

Original Poster
Rep: Reputation: 15
Audio

k thank you as u said i gave ./a.out plughw:0,0 / hw:0,0 but got this error ALSA lib pcm_hw.c:1429_snd_pcm_hw_open) Invalid value for card
cannot open audio device (No such file or directory)
 
Old 07-15-2010, 04:24 PM   #7
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
You should use the same PCM that works also with "arecord -D pcm". Try the PCM "default" and see, if it works.
 
Old 07-20-2010, 09:21 AM   #8
puneeth bhat
Member
 
Registered: Jan 2010
Posts: 30

Original Poster
Rep: Reputation: 15
Unhappy Audio

Hi ALL,
i compiled the capture program given in the above link by passing the argument hw:0,0 bt getting the segmentation fault as below when i run gdb...Please kindly help i m not able to open the device and capture the sound..

Breakpoint 1, main (argc=1, argv=0xbff3bbc4) at captest.c:13
13 if ((err = snd_pcm_open (&capture_handle, argv[1], SND_PCM_STREAM_CAPTURE, 0)) < 0) {
(gdb) s
a.out: pcm.c:2210: snd_pcm_open: Assertion `pcmp && name' failed.

Program received signal SIGABRT, Aborted.
0xb7d15c66 in raise () from /lib/libc.so.6
 
Old 07-20-2010, 12:04 PM   #9
irmin
Member
 
Registered: Jan 2010
Location: the universe
Distribution: Slackware (modified), Slackware64 (modified), openSuSE (modified)
Posts: 342

Rep: Reputation: 62
It does not look like you passed one argument to your program, because argc==1 as you can see from gdb output. You will have to use
Code:
set args hw:0,0
in gdb prior to starting the program. Your program aborts because argv[1] is NULL in your case.
 
Old 07-21-2010, 12:49 AM   #10
puneeth bhat
Member
 
Registered: Jan 2010
Posts: 30

Original Poster
Rep: Reputation: 15
Angry Audio

I m extremely sorry for that previous post i have passed argument with executable got the seg fault bt i didnt pass while i was checking with gdb....i have attached gdb output..hope this helps u little more to figure out...
and this is what i get when i gave command aplay -l...

**** List of PLAYBACK Hardware Devices ****
card 0: ICH6 [Intel ICH6], device 0: Intel ICH [Intel ICH6]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: ICH6 [Intel ICH6], device 4: Intel ICH - IEC958 [Intel ICH6 - IEC958]
Subdevices: 1/1
Subdevice #0: subdevice #0
i have tried even giving all the combinations hw:0,0 0,4 bt results are same...


This GDB was configured as "i486-slackware-linux"...
(gdb) b main
Breakpoint 1 at 0x80487ee: file captest.c, line 13.
(gdb) r hw:0,0
Starting program: /home/puneeth/a.out hw:0,0
[Thread debugging using libthread_db enabled]
[New Thread 0xb7c876c0 (LWP 3408)]
[Switching to Thread 0xb7c876c0 (LWP 3408)]

Breakpoint 1, main (argc=2, argv=0xbfe22294) at captest.c:13
13 if ((err = snd_pcm_open (&capture_handle, argv[1], SND_PCM_STREAM_CAPTURE, 0)) < 0) {
(gdb) s
20 if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0) {
(gdb) s
26 if ((err = snd_pcm_hw_params_any (capture_handle, hw_params)) < 0) {
(gdb) s
32 if ((err = snd_pcm_hw_params_set_access (capture_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) {
(gdb) s
38 if ((err = snd_pcm_hw_params_set_format (capture_handle, hw_params, SND_PCM_FORMAT_S16_LE)) < 0) {
(gdb) s
44 if ((err = snd_pcm_hw_params_set_rate_near (capture_handle, hw_params, 44100, 0)) < 0) {
(gdb) s

Program received signal SIGSEGV, Segmentation fault.
0xb7e6ec24 in ?? () from /usr/lib/libasound.so.2
(gdb)
 
  


Reply

Tags
recording


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Audio Chat Programming anirbanghosh Programming 1 04-08-2010 02:04 PM
Audio programming hitchhikr Programming 3 01-29-2009 01:46 PM
portable audio programming PatrickNew Programming 3 07-16-2007 10:42 PM
OSS Audio Programming jinksys Programming 0 10-11-2003 03:17 AM
kernel audio programming ksnash Programming 0 08-04-2003 10:19 AM


All times are GMT -5. The time now is 02:56 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration