I'm writing an OpenAL wrapper library for my needs and stumbled into the limited source/buffer count problem. On two of my PC's with different sound hardware I can't create more than 25 OpenAL sources and buffers. Obviously, 25 unique sounds arent't enougn for a game that's a bit more complex than Pacman, for example. So I have to manage the sources and buffers on my own in a way that only important sounds in any given moment are bind and played.
Is something like this goind to work. :
I load the sound data from the hard disk into my own sound buffers, that are simply chunks of memory full of bytes. I keep a list of those sound buffers. When I need a sound to be played, and that sound is important, I search the list of sound evaluate their importance and priority and if I found a sound that could be omitted or ignored, I simply do
[source lang="cpp"]ALuint freeSound = findFreeSoundSlot() ; alBufferData(Buffers[freeSound] , SoundToBePlayed->format, &SoundToBePlayed->data, SoundToBePlayed->size, SoundToBePlayed->freq);// Bind the buffer with the source.alSourcei (Sources[freeSound], AL_BUFFER, Buffers[freeSound] ); alSourcePlay(Sources[freeSound]);[/source]
My questions are :
Is that a good way to overcome the OpenAl source/buffers limitation ?
How do you people manage your sounds ? Could you give an example in pseudo or actual code snippets ?
Is there a place, a link, an open source library, a tutorial where I can see how to manage my sounds ?
Edited by solenoidz, 02 December 2012 - 02:13 PM.