Sign in to follow this  
d3x

releasing sound buffer

Recommended Posts

here's the situation i have a class called DirectSound. i have a function DirectSound::PlaySound(char* fileName) what that function does is: -opens wav file and gets header info about wav file like channels, bits per second... -creates static secondary buffer based on the heade info of the wav file and copies sound data from file to secondary buffer -plays that secondary buffer using SoundBuffer ->Play(...); -then after that function i've put a function to release that buffer the program releases the secondary buffer before the file starts to play because just after the function Play(...) i called Release(); when i remove call to Release function the buffer plays normally and the parent function PlaySound finishes BUT the buffer stays in memory its not released. I've been doing some thinking about it and maybe it's best to create one more function in class DirectSound that releases the sound buffer AFTER the sound has finished playing. And to make linked list of pointers to sound buffers currently playing so i can release them when they stop. so class DirectSound { function PlaySound - plays the buffer and saves the pointer to sound buffer to linked list function ReleaseSound - checks if any of the sounds are finished playing and immediatelly releases that sound buffer linked list here with pointers to sound buffers currently playing } BUT... i want the program to call the function ReleaseSound WHEN a sound has fiished playing. so is there a way to make my program send notification when a buffer has stopped playing and automatically call Release function? i looked on the internet that this can be implemented by EVENTS but i dont really know how to do that. My problem is identical to this problem. What if i want to make a program to do something at the time I choose lets say i want to tell program to beep at 10.00AM . How can i do that? The first thing i come up with is to make a constant program loop that constantly checks if its 10.00AM and if it is send a beep if its not check again and so on... I looked at quake3 source code but didnt find anything yet too complicated... Im sorry for a big post guys... Please help the future game developer...

Share this post


Link to post
Share on other sites
anyone ever implemented multiple sound buffers playing in game??
if yes, how was your system implemented, how did you release the buffers after they have finishd playing??

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this