LinuxQuestions.org
Review your favorite Linux distribution.
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 07-04-2005, 12:12 AM   #1
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Rep: Reputation: 15
writing a c program in linux which plays an'.wav' file


right now my work requires that i need to write a program in linux using c which will play a '.wav' files i tried a lot of searching but could not find a particular function in linux which will write into the speaker port. if anybody could help me i would be very grateful for that.
 
Old 07-04-2005, 12:27 AM   #2
freegianghu
Member
 
Registered: Oct 2004
Location: somewhere in the street
Distribution: Window$
Posts: 192

Rep: Reputation: 30
Re: writing a c program in linux which plays an'.wav' file

Quote:
Originally posted by stephenwalter
right now my work requires that i need to write a program in linux using c which will play a '.wav' files i tried a lot of searching but could not find a particular function in linux which will write into the speaker port. if anybody could help me i would be very grateful for that.
Have a look at Audio Howto

Hopes it help
GH
 
Old 07-04-2005, 04:46 AM   #3
64bitprocessor
LQ Newbie
 
Registered: Jul 2005
Location: Bangalore
Distribution: Debian
Posts: 15

Rep: Reputation: 0
HI,
In normal Linux distributions a special character device file /dev/dsp is used from recording an playing sound. IF something is written into this file it will be played through the computer. lly we can record sound by reading from the device file. We can use the system calls open(), close(), read(), write() etc.. in this file. ioctl calls are used for controlling the sound card. Search for some documents about OSS (Open Sound Systems) in the net.
We ha a special library libsndfile for converting sound files in Linux. It may also help you a lot. See the http://www.mega-nerd.com/libsndfile/ for more details.
 
Old 07-04-2005, 03:12 PM   #4
newbie007007
Member
 
Registered: Dec 2004
Location: India
Distribution: Fedora
Posts: 36

Rep: Reputation: 15
HI,
In order to play a .wav file , you need to read the wav data from file and write it to /dev/dsp.
You should also set the audio device to settings of the .wav file.
I mean some files has 2 channels and some has only 1 channel.
Some files have a speed of 44100 and some have 22050.
Also the bitrate.
Every wav file has a header that gives you the above details.(channels,speed,bitrate).
After reading the above info from the .wav file you need to set the audio device to the settings of the .wav file to be played.
You can set the device by using the ioctl() system call.
Go for google to know more about ioctl system call and .wav format.
I have done it before(both playing and recording) and it worked fine for me.

regards.
 
Old 07-06-2005, 01:23 AM   #6
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Original Poster
Rep: Reputation: 15
hi
i would like to thank all four of you for providing me with so much info. i learnt a lot on the links provided and it has made my work look easier. Thank you very much
 
Old 07-08-2005, 06:46 AM   #7
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Original Poster
Rep: Reputation: 15
hi
i need to clear one more doubt does OSS(open sound system) support the AMR encoding format.
 
Old 07-08-2005, 01:46 PM   #8
Chrax
Member
 
Registered: Apr 2004
Distribution: Dapper
Posts: 167

Rep: Reputation: 31
I believe OSS is deprecated and ALSA is the standard.
 
Old 07-08-2005, 11:37 PM   #9
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Original Poster
Rep: Reputation: 15
hi charx,
Thank you for the information . I also know that ALSA is the current standard , But iam required to work on the OSS driver currently. Do u know anyway whether the ALSA driver has support for the AMR speech encoding format.
 
  


Reply


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing DVD's in Linux with file size over 2 gb haoscar Linux - Software 64 05-03-2005 05:01 AM
Need help writing a mp3->wav script... Vincent_Vega Linux - General 7 12-29-2004 11:10 PM
writing a simple file system in linux Deepthi_57 Linux - Newbie 1 05-03-2004 12:42 AM
Looking for a program that plays vqf dj_olsen Linux - Software 1 10-06-2003 04:29 AM
Windoze .wav vs. Linux .wav Raskall Linux - General 6 01-15-2003 06:19 AM


All times are GMT -5. The time now is 10:40 AM.

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 Google+: linuxquestions
Open Source Consulting | Domain Registration