LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 05-10-2004, 08:54 PM   #1
khucinx
LQ Newbie
 
Registered: May 2004
Posts: 23

Rep: Reputation: 15
Question how to play sound file with c code?


anyone help me please...

i have a login code for linux ( c code )

i want to play sound file and record sound from the
audio input in linux. but there are no shell. because
that code will be run at the login time, so no shell
to be run before login succesfull, exactly i have to
use c code.

in other word, i want to add c code that can play and
record sound to login in linux. anyone help me, how?
 
Old 05-11-2004, 06:28 AM   #2
cjp
Member
 
Registered: Dec 2003
Location: the Netherlands
Distribution: SuSE 9.0
Posts: 54

Rep: Reputation: 15
I don't really understand the shell-problem. Can you explain that more? That will give me a view of the situation. It seems that you don't want to use C but that you feel forced to do so. Why?

About sound in C: you have two options.
1: use the audio devices directly (e.g. /dev/dsp; you can access them just like files)
2: use an audio library that does the work for you

If you want to do complicated things (like playing mp3's, mod files, or dsp), then the second one is the only realistic one. But if you only want to do simple things, then you can use the first one.

For example if you have a file that plays nice with
cat soundfile > /dev/dsp

then you can do almost the same in C. Just open the sound file for reading, open /dev/dsp for writing and read & write bytes till the end of the file.
 
  


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
I can't hear any sound when I play a cd or mp3...but tested with system tools->Sound Niceman2005 Linux - General 6 10-31-2005 09:51 AM
FC2: Sound Card (SiS SI7012) Detect But Donot Play Sound rajanaeem Linux - Hardware 0 10-22-2004 03:41 PM
when i try to play a sound file with mpg123 or mpg321 i get an error VioLaToR Linux - Software 5 02-24-2004 12:25 PM
How to play a media file/ video file/mp3 file recorded in harddisk/cd-rom arindam Linux - Newbie 2 09-05-2003 10:31 AM
unable to play more than one sound file at a time. wonka_vision Linux - Hardware 2 06-10-2003 06:22 PM

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

All times are GMT -5. The time now is 01:22 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