[SDL] Question about SDL_sound

Trevor Agnitti trevor at lackeyccg.com
Wed Dec 6 01:31:21 PST 2006


I have a question about SDL_sound.  Is it appropriate to ask about  
SDL_sound in this mailing list?  If not, where should I ask?

I am wondering about loading and playing sounds.  I want to load a  
sound (like an interface sound) once, and then play it as many times  
as I want without it loading more than that initial load.  I have  
looked all over the web for an example of this, and I cannot find one.

The examples on the web I have found involve reloading a sound every  
time it is played.  What some examples do is set up a callback that  
reads a certain amount from the sound file, plays that amount, and  
then reads in more of the file and plays it, and so on until the  
whole sound file has been played.  I am wondering if this type of  
thing is done out of necessity because of the potentially large  
amounts of memory that cannot be stored for the duration of a program.

Here is one example I found:
Sound_MixInit(NULL);  // start the mixer; don't care what format.
Sound_Sample *hello = Sound_NewSampleFromFile("hello.wav", NULL, 10240);
Sound_Sample *music = Sound_NewSampleFromFile("icculus.ogg", NULL,  
10240);
Sound_SetAttribute(hello, SOUND_ATTR_FIREANDFORGET, 1);
Sound_SetAttribute(music, SOUND_ATTR_FIREANDFORGET, 1);
Sound_MixPlay(music);

Does anyone know of a bit of sample code that loads a sound file once  
and allows for playing it again and again without reloading it?

I think that not having to reload a file would be a lot faster than  
reloading it.
Can someone please direct me to a good site explaining this or at  
least tell me if what I want to do is not possible?

Thanks in advance.
-Trevor
http://www.lackeyccg.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20061206/77a0a621/attachment.htm 


More information about the SDL mailing list