Sources in OpenAl
Posted 06 October 2004 - 08:41 AM
in Open Al doc. is writen this:
The AL has three fundamental primitives or objects Buffers, Sources, and a single
Listener. Each object can be changed independently, the setting of one object does not affect the setting of others. The application can also set modes that affect processing. Modes are set, objects specified, and other AL operations performed by sending commands in the form of function or procedure calls. Sources store locations, directions, and other attributes of an object in 3D space and have a buffer associated with them for playback. There are normally far more sources defined than buffers. When the program wants to play a sound, it controls execution through a source object. Sources are processed independently from each other.
well, i can have 32 sources max., but i have more than 100 sound sources in my level, but they are not played at once.
Question is: what is good way to manage sources ?
i want to create 100 sources and select 32 of them to play at once, but i dont know how to do it. :(
Posted 06 October 2004 - 01:46 PM
I create all the sound buffers that i will be playing in the level/room whatever
I already have a list of sources (up to the max available)
I request a sound to be played from a given buffer
I look through the array of sources, checking their state as i go (playing, paused stopped etc.)
I find a source that is not playing, i play the requested sound on that source
And so on and so on.
If I have no sources availabe the sound doesnt get played (you could have a priority system running in that case, where certain sounds have a higher priority that others)
I then return the source that the sample has been played on to allow the system to control the source
100's of samples (buffers) is a lot. How many of these would you exxpect to be played at the same time? Repeating sounds can all be played from the same buffer, so dont load in mutiple instances of te same buffer (just in case you are)
Hope that helps a little
Posted 06 October 2004 - 01:51 PM
i have an array of all the sources each source containing info off it's id and position.
then i have an array of all currently playing sounds it's length is 32!
at last i have an integer variable which contains the number of playing sources.
(i'm trying to implement a function that sorts the sources by distance from listener but that'll come later..)
when i want to play a source i set playingarray[playingsources] = sources[the one i want to play];
and increment playingsources;
test to see if playingsources is higher than 32; if it is then set it to 1!
guess it can be made a little smarter but that works until now
Posted 06 October 2004 - 02:55 PM
sometimes there is more than 32 sounds at once.
priority on sounds can work good. only not important sounds are not played, there is a little problem with setting distancies on sounds, because it can be set wrong and not playing some sounds can sounds strange.
i'm going to implement this, and i will write here results.
Posted 06 October 2004 - 05:07 PM
Posted 21 October 2004 - 07:05 AM
It is functional, but i think there is some place to improvements.
Who is interested to share knovledge to develop sound engine in 3d game, and is interested in source code let me know.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users