LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to play sound file with c code? (https://www.linuxquestions.org/questions/programming-9/how-to-play-sound-file-with-c-code-180135/)

khucinx 05-10-2004 08:54 PM

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?

cjp 05-11-2004 06:28 AM

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.


All times are GMT -5. The time now is 12:32 PM.