Advertisement

multiple openAL buffers playing on one sound source?!

Started by December 31, 2002 06:58 AM
6 comments, last by billybob 20 years, 8 months ago
how do i make multiple sounds play from one source at a time? i know i can queue buffers, but it doesn't do much good if the engine sound gets queued after the tire skidding sound which is queued after the horn sound. do i have to make a source for every sound? edit: lol, forgot to say its openAL that i'm using. [edited by - billybob on December 31, 2002 8:15:06 AM] [edited by - billybob on December 31, 2002 8:15:28 AM]
disclaimer: I''m totally new to openAL.

Answer:

Yes. Each individual sound needs it''s own source. Multiple sources can have the same position/velocity/etc.
--Mark
Advertisement
In OpenAL you are limited by sources ( depending on your hardware ), but you can have has many Buffers as you want.

So, load all your sound to the buffers you want.
Then, create a source only for the sound that you are about to play, and keep checking when the sound finishes., when the sound is finished playing, delete the source..

From the top of my head, something like this :

alGetSourcei(g_Source, AL_SOURCE_STATE, &play);
if(play == AL_STOPPED)
{
alDeleteSources(1, &g_Source);
}


I did this in my engine, and while you can have 300 sounds loaded, you will only play 10 or something at once, so when you finish playing one of them, delete the source immediatly, so that the source can be used again by other sound
That looks like a really horrible way to manage sound sources.

Why not have each object capable of generating noise create
a source and keep it around for the duration of its lifetime?

So, an object may make noise multiple times before it dies,
yet it''s only using one source.

class SomeObject    {    public:        SomeObject() { alGenSources(...); }        ~SomeObject() { alDeleteSources(...); }        MakeNoise() { alSourcePlay(...); }    }// end



Kami no Itte ga ore ni zettai naru!
神はサイコロを振らない!
Yes, it''s not very pretty , but as i said before, you have limited sources., if you create 100 objects in-game, with each one making one sound having one source, you will run out of sources very fast.
Hmm... OK, just how limited are we talking about? 10? 100?
1000? I can see a small cap on the number of sources playing
a sound *simultaneously*. But why a low limit on the number
of created sources? I''d think it''s limited by available
memory.



Kami no Itte ga ore ni zettai naru!
神はサイコロを振らない!
Advertisement
We are talking about very limited., in my sound card i think i have 32 sources, however i have seen sound cards with 8 sources ( old sound cards ).
As far as i can see, there''s no software sound sources in Openal.
Also prioritize your sounds for when things get especially busy. It makes no sense to continue playing the sounds of wind or rain when there are bombs exploding everywhere.
-solo (my site)

This topic is closed to new replies.

Advertisement