Jump to content

  • Log In with Google      Sign In   
  • Create Account

OpenAL sound management


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 solenoidz   Members   -  Reputation: 530

Like
0Likes
Like

Posted 02 December 2012 - 02:06 PM

Hello people.
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 ?

Thank you!

Edited by solenoidz, 02 December 2012 - 02:13 PM.


Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 13576

Like
1Likes
Like

Posted 02 December 2012 - 02:16 PM

Are you sure this is a real-world situation and not just cheap hardware on your part? Even iPhones support 1,024 buffers at a time.

In any case, when new sounds present themselves, your management system should evaluate that sound’s priority and the priorities of other sounds in order to determine if it should be played and if so which sound it should overwrite.
The priority of any given sound, whether about to be played or already playing, is based off its baseline priority vs. its distance from the player. Quiet sounds have a lower priority no matter what their baseline priority is, whereas sounds of similar volume will be decided by the baseline.
Remember to determine the new sound’s priority before playing it, since it may be farther away and lower-priority than any sound that is already playing.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 _swx_   Members   -  Reputation: 937

Like
1Likes
Like

Posted 02 December 2012 - 03:53 PM

http://research.ncl.ac.uk/game/mastersdegree/workshops/audio/Sound%20Workshop.pdf

#4 solenoidz   Members   -  Reputation: 530

Like
0Likes
Like

Posted 03 December 2012 - 08:18 AM

Thanks guys.

Are you sure this is a real-world situation and not just cheap hardware on your part? Even iPhones support 1,024 buffers at a time.


Well, its seems I was using the wrong tutorial that made the same number of sources and buffers via a global #define NUM_BUFFERS
I wasn't checking the error state after every OpenAL call, so alGetError() returns error not by the number of buffers, but obviously the number of sources was too high.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS