LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   How can I efficiently play a sound (under Linux) (https://www.linuxquestions.org/questions/programming-9/how-can-i-efficiently-play-a-sound-under-linux-204748/)

JonnyW247 07-13-2004 11:09 PM

How can I efficiently play a sound (under Linux)
 
I have tryed using a fork() and exec() to run esound but this method is very slow and I am curious if anybody know of any functions/libraries that can be used to play a sound efficiently and not have to wait half a second for esound to load up and play.

thanks

JW

dalek 07-14-2004 04:36 AM

If you have aplay installed, type in aplay /path/to/sound/file

That should work for root and users.

Later

:D :D :D

JonnyW247 07-14-2004 04:47 AM

Thats not really the point I was getting at... heh

you see, typing in a command such as aplay, or esdplay, is done by calling that program to run - essemtially it is a command line.

To do this, in programming, you do a fork() and then a form of exec() to run that file.

There is about a 1/4 of a second delay for this method to finally kick in and the sound to start playing... Thats bad for what I want it to do.


Now, I could use OpenAL, but, what I was getting at, is there an easy way to get it to play a sound file without having to go through some elaborate API/SDK???

In windows, you could just include windows.h and do a PlaySound() function, simple as that. In linux, is there a similar methodology without having to do the slow fork/exec??


Thanks for the reply tho,

JW

Mega Man X 07-14-2004 05:01 AM

SDL API is what you seek:

http://www.libsdl.org/intro/usingsound.html

stpg 07-14-2004 07:50 AM

http://www.fmod.org/ and all sound world is in your hands


All times are GMT -5. The time now is 11:37 PM.