Hi, I'm new to using OpenAL, and I wanted to play just a simple sinewave. But I wanted to know if it's possible toplay multiple sounds at one time. Perhaps playing more than one buffer in one source, or playing multiple sources at the same time. Any help would be greatly appreciated. Thanks in advance
Playing Multiple Sounds
Started by jeeva86, Nov 01 2005 09:32 PM
5 replies to this topic
#1
Posted 01 November 2005 - 09:32 PM
#2
Posted 01 November 2005 - 11:14 PM
You can only play one buffer on a single source. To play multiple sounds at the same time means using a single buffer (which contains the sample you wish to play), and assigning it to multiple sources.
It's pretty simple to do, and the articles here on DevMaster should easily show you how to do it.
Spree
It's pretty simple to do, and the articles here on DevMaster should easily show you how to do it.
Spree
#3
Posted 03 November 2005 - 03:01 AM
By playing the same buffer with multiple sources? Wouldn't that just play the same sound on top of each other? I want to play different frequencies using the alutCreateBufferWaveform function.
#4
Posted 03 November 2005 - 09:41 AM
No, this is not the case. When the source is playing a buffer, it will read the buffer, then alter it according to the properties set via the source, not the buffer.
So for example, if you have explosion.wav which has been loaded via alut. That buffer is now loaded, and unless you want to do any sound pre-processing, doesn't need to be altered in any way.
Now, if you want to play 4 explosions, all with slightly different frequences to make it more varied, you play the same buffer on 4 different sources. If you want to change the frequency, you change the frequency of the source and not the buffer. This will give you four sounds, played seperatly, with varying frequences (and volumes etc.), all played off one buffer.
It would only play the same sound on top of each other if you played the same sample, with no variation, at the exact same time in the program. And yes, that would sound crap.
If you need more information, have a look at this tutorial...
http://www.devmaster...als/lesson5.php
Spree
So for example, if you have explosion.wav which has been loaded via alut. That buffer is now loaded, and unless you want to do any sound pre-processing, doesn't need to be altered in any way.
Now, if you want to play 4 explosions, all with slightly different frequences to make it more varied, you play the same buffer on 4 different sources. If you want to change the frequency, you change the frequency of the source and not the buffer. This will give you four sounds, played seperatly, with varying frequences (and volumes etc.), all played off one buffer.
It would only play the same sound on top of each other if you played the same sample, with no variation, at the exact same time in the program. And yes, that would sound crap.
If you need more information, have a look at this tutorial...
http://www.devmaster...als/lesson5.php
Spree
#5
Posted 03 November 2005 - 12:50 PM
I get what you're trying to say, but just last night, I tried this and it worked. I had created 5 buffers and 5 sources. Loaded each buffer to its seperate source and played all sources. It did the job. Is it much different from what you're saying.
#6
Posted 03 November 2005 - 01:23 PM
You can do it that way if you want, but it is a total waste of memory, as your using 5x more than what you need.
Also, what happens when you think you need 3 explosions, but then another one happens? Are you going to load the sample again?
It will work, but it is a very wasteful, slow and bloated way of doing things.
Spree
Also, what happens when you think you need 3 explosions, but then another one happens? Are you going to load the sample again?
It will work, but it is a very wasteful, slow and bloated way of doing things.
Spree
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











