LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 03-30-2007, 01:32 PM   #1
ashlesha
Member
 
Registered: May 2005
Location: PA
Distribution: Ubuntu
Posts: 204

Rep: Reputation: 30
dev file for speakers and microphones


what is the name of the device file that represents the microphone and the loudspeaker in Ubuntu? i can see a char device called audio in /dev.

If this is the microphone file, then is reading from it as simple as using fopen and fread?


Thanks,
Ashlesha.

Last edited by ashlesha; 03-30-2007 at 01:36 PM.
 
Old 03-31-2007, 04:15 PM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
I'm pretty sure your sound card is treated as a single device, despite however many inputs and outputs it may have.

Give it a shot - try using fopen() and fread(), what's the worst that could happen?
 
Old 03-31-2007, 06:53 PM   #3
ashlesha
Member
 
Registered: May 2005
Location: PA
Distribution: Ubuntu
Posts: 204

Original Poster
Rep: Reputation: 30
ok, i will try that --- i have another question though --
say I have a wav file that i want to play at 8kHz -- is there a way to calculate how many processor cycles are taken up by each instruction in my program so that I can output the file at exactly that frequency?

Thanks,
ashlesha.
 
Old 04-01-2007, 11:59 AM   #4
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65

I wish I could answer you on this one, but that's very much past any of my knowledge.

You'd probably want to direct your question to a C buddha, or a Linux-80x86 ASM programmer.
 
Old 04-09-2007, 02:51 PM   #5
clb
Member
 
Registered: Sep 2004
Location: UK
Distribution: Ubuntu
Posts: 117

Rep: Reputation: 16
I believe the soundcard is /dev/dsp. Not sure about the microphone though, but sound out definitely works through /dev/dsp. You can do cat "afile" > /dev/dsp and the speakers will make an annoying buzzing noise.

Hope this helps,
Chris
 
Old 04-09-2007, 05:08 PM   #6
burninGpi
Member
 
Registered: Mar 2006
Location: Fort McMurray, Canada
Distribution: Gentoo ~amd64
Posts: 163

Rep: Reputation: 30
There are some other files in /dev/sound, but that's probably system-dependent.

/dev/dsp is used with the OSS API. The documentation for OSS might be of use (I'd post a link, but I haven't done any sound programming).

EDIT: Oh, and don't cat anything to the dev file; it'll make some odd noise if you're lucky, and make some loud, odd noise if you aren't.

Last edited by burninGpi; 04-09-2007 at 05:11 PM.
 
Old 04-11-2007, 12:02 PM   #7
clb
Member
 
Registered: Sep 2004
Location: UK
Distribution: Ubuntu
Posts: 117

Rep: Reputation: 16
I shall remember that burninGpi, can't remember where it was I read about cating things to /dev/dsp - someone advised me to in order to test sound. Didn't realise it was OSS specific though, thanks
 
Old 04-11-2007, 12:18 PM   #8
hacker supreme
Member
 
Registered: Oct 2006
Location: As far away from my username as possible
Distribution: Gentoo
Posts: 259
Blog Entries: 1

Rep: Reputation: 31
you can cat RAW audio files to /dev/dsp. It works very well. Just be very careful that you don't cat your sound input to /dev/hda. Never been there. Never want to!

BTW: Also works with .wav files.
 
Old 04-11-2007, 12:33 PM   #9
omnio
Member
 
Registered: Feb 2007
Location: $HOME
Distribution: Hardened Gentoo
Posts: 66
Blog Entries: 1

Rep: Reputation: 16
Quote:
Originally Posted by clb
I shall remember that burninGpi, can't remember where it was I read about cating things to /dev/dsp - someone advised me to in order to test sound. Didn't realise it was OSS specific though, thanks
I remember something like:
Code:
cat /dev/urandom > /dev/dsp
(you can try that, don't worry - just be prepared and lower the volume before doing it (master and pcm).

Last edited by omnio; 04-11-2007 at 12:36 PM.
 
Old 04-11-2007, 08:41 PM   #10
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,786

Rep: Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083Reputation: 2083
Here's an articles that has some examples of this with recording too: http://www.linuxjournal.com/article/2793

Code:
# record 4 seconds of audio from microphone
% dd bs=8k count=4 </dev/audio >sample.au
# play back sound
% cat sample.au >/dev/audio
From C I guess you can use OSS or ALSA. ALSA is supposed to have an emulation layer for OSS so that should still work even if you're using ALSA (it is possible to disable the emulation via kernel compilation options).
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Skype & microphones / mics TheOracle Linux - General 3 12-24-2007 06:00 AM
headset's microphones adds lot of noise to the voice minike Linux - Hardware 2 12-20-2006 01:14 PM
Questions about Cron, Microphones, Networking and Amarok with Gstreamer roastedmnm SUSE / openSUSE 2 02-17-2006 10:02 PM
Anyone with experience in microphones...... ksoma General 7 09-19-2004 02:29 PM
Microphones for live streaming audio Dave Kelly Linux - Hardware 4 08-22-2004 01:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration