   direct sound problem - app eats memory
  hi,I have nearly no experience with sound handling.In my game I have created a soundBuffer for every sound effect.When I want to play an effect I do this:   LPDIRECTSOUNDBUFFER play;lpds->DuplicateSoundBuffer(existingSoundEffect,&play);play->Play(0,0,0);Now I found out that directX eats memory for every sound effect that is played in my app. How can I mix sound effects in my game with a constant amount of memory?byechris 
  i'm not sure i understand your question.  A sound is a bunch of data.  to have that sound in memory you'll obviously use memory.  the more sounds you have, the more memory that you'll use.if you want to conserve memory for sounds, don't hold all sounds in memory all the time.  certainly your monster sounds don't need to be in memory if there are no monsters that could possibly encounter the player.  so only load them into memory when a monster is close to the hearing range of the player.I dunno, can you be more clear about what you mean by "constant memory".[Edit: ...So do you really need to be making a DuplicateSoundBuffer every time you play a sound?  also, where are you deleting that sound buffer?  or does DirectPlay delete it for you.  if you mean that you are having memory leaks then the problem is that you aren't deleting the duplicate sound buffer.  if you mean that playing sounds uses more memory, it's because you are duplicating the sounds buffer....  maybe you don't need to duplicate it???]-me   [edited by - Palidine on February 19, 2004 2:16:22 PM];  hithanks for the reply. I duplicate the buffer, because when sounds are overlapping (i.e. explosions) I need to create a new sound buffer, because directSound only mixes sounds beeing played from different sound buffers. If I had only one sound buffer for the explosion effect and there were many explosions following each other in short intervals, directSound wouldn't mix the sounds.With "constant memory" I mean, that there are no memory allocations while running the games due to sound effects.As I said, I have nearly no experience with sound handling in games, and I don't know the technique to do it.byechris   [edited by - Zoomby on February 19, 2004 2:27:02 PM];  what does this mean?quote:Original post by Zoomby   With "constant memory" I mean, that there are no memory allocations while running the games due to sound effects.to me it means that your app is broken now because when you are playing sound effects, you run out of memory and all calls to new return NULL.  if that's the case then you are either: playing way to many sounds or your sounds are far to big memory-wise.  if the latter just whip out a sound editing program and start making them smaller.i think what you need is a basic memory manager.  Something that allocates a big block of memory when you launch your app.  then you override the new/delete operators to use your memory manager instead of calling to the OS.  you also need a sound manager that can evaluate the amount of memory that the sound app is using by hooking into the memory mananger.  give it a budget of memory that it can use.  if it's going over that budget, don't allow sounds to play.  to make things cleaner, give different types of sounds different priorities.  i.e. an explosion sound must play or it will look wierd.  but ambient sounds can drop out without too much effect.  that way, when the budget gets tight, you start dropping out the less important sounds and still manage to play the important ones.  it's essentially the same thing as graphical or ai scaling for performance.-me   [edited by - Palidine on February 19, 2004 2:33:37 PM];quote:Original post by Palidine   you run out of memory and all calls to new return NULL.Or they throw std::bad_alloc, unless you pass std::nothrow_t to the new function. Just being pedantic  [edited by - CloudNine on February 19, 2004 2:38:10 PM];  Are you releasing the duplicate sound buffer?;  hi,yes I need some kind of sound management. But I don''t know how to do it.maybe I need a pool of sound buffers. but when I want to play a sound I would need to copy the sound data of the effect into a free buffer from the pool. But the only way to copy a buffer would be to lock and unlock it. Wouldn''t that be slow?Is this the way to do it? bye chris ;  hi,@Cor:thanks for the tip! I didn''t saw that there is a release method for sound buffers to! :-)byechris