LinuxQuestions.org
Help answer threads with 0 replies.
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-13-2004, 11:09 PM   #1
JonnyW247
LQ Newbie
 
Registered: Jan 2004
Posts: 11

Rep: Reputation: 0
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
 
Old 07-14-2004, 04:36 AM   #2
dalek
Senior Member
 
Registered: Jul 2003
Location: Mississippi USA
Distribution: Gentoo
Posts: 2,058
Blog Entries: 2

Rep: Reputation: 79
If you have aplay installed, type in aplay /path/to/sound/file

That should work for root and users.

Later

 
Old 07-14-2004, 04:47 AM   #3
JonnyW247
LQ Newbie
 
Registered: Jan 2004
Posts: 11

Original Poster
Rep: Reputation: 0
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
 
Old 07-14-2004, 05:01 AM   #4
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,337

Rep: Reputation: 65
SDL API is what you seek:

http://www.libsdl.org/intro/usingsound.html
 
Old 07-14-2004, 07:50 AM   #5
stpg
LQ Newbie
 
Registered: Jun 2004
Distribution: Fedora Core 2
Posts: 11

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


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
Cannot play sound in Linux Taurussoft Linux - General 1 09-28-2005 05:18 AM
linux sound can not play on workstations banner Linux - Newbie 3 09-13-2005 12:09 PM
Enemy Territory does not play sound in ubuntu linux sabot Linux - Games 6 06-15-2005 05:07 PM
I play doom3 in linux but no sound. ayiiq180 Linux - Software 1 10-25-2004 11:22 PM
need help for sound recording and play back in linux redhat? nick27 Programming 4 02-17-2004 09:02 PM

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

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