Hello, I’m calling FSOUND_GetMemoryStats(*int, *int) and i notice that the amount of memory consumed by FMOD is getting huge, fast. In my game, i have characters make certain sounds when certain events happen.
I load and play the sounds via something like:
FSOUND_SAMPLE *sample = FSOUND_Sample_Load(SOUND_FREE, “fireArrow.wav”, 0, 0);
int channel = FSOUND_PlaySound(FSOUND_FREE, sample);
If i put FSOUND_Sample_Free() as the next statement then i don’t hear the sound, as it is cut off as soon as it begins. So I obviously don’t do that.
How can i have the sound samples freed from memory as soon as they finish playing? I considered something like:
But then the entire thread would have to wait for the sample to finish playing just to reclaim the memory.
Would the best way be to load all of the samples i intend to play as soon as the game starts as opposed to loading each sample each time it needs to be played (So that at least only one instance of the sample will be in memory). This hardly seems ideal.
Please can somebody tell me if it is possible to have a sample “free itself” from memory after playing.
- ProgrammingWorlds asked 16 years ago
Through normal ways it is not possible to have a sample freed as soon as it finishes playing. Doing that would only be wise for samples that aren’t gonna be played for some time; otherwise there would be constant hard disk usage…(very annoying)
Establish sound priorities: The sound with the highest possibility of playback plus its possibility of playing more than once gets the highest priority.
These priorities don’t have to be static: it is likely that a sound which was played often in the last run is also played often in the current run.
Now load sounds starting with the highest rated one until you have no memory left.
All other sounds might as well be loaded as streams.
- night answered 16 years ago
You could have the streams delete themselves in a way by supplying your own callback function to FSOUND_Stream_SetEndCallback(). When the stream reaches the end of the sample, your function is called, at which time you can formally close the stream.
- johnnie2 answered 16 years ago
Please login first to submit.