instance of a sound?

Grom

09-02-2007 11:32:45

First off let me say thank you for the most painless installation / implementation i've ever experienced. It took me longer to download the libraries than to build them and get sound effects and music into my application. Thank you.

The question I have is in regard to playing a sound repeatedly, with the possibility of it being played overtop of itself. Basically, I have a gun, and I want it to play wave file every time it fires. The gun is automatic, so the wave needs to be played in rapid succession and while previous instances of itself are still finishing out their play cycle.

How sould I go about doing this? Should I create like 20 copies of the same wave, and loop through them as needed? That seems hackish. Is there a way to do what I'm asking?

Martins1

09-02-2007 11:41:43

May be you could create a sound, which when played continuously
(looped) sounds like an automatic gun?

t0tAl_mElTd0wN

09-02-2007 13:37:38

Thanks for the compliment! Gotta point to CaseyB for that one.

mySound->setLooping(true);

http://www.mooproductions.org/ogreal/api/0.2/index.html

Have fun!

Grom

09-02-2007 15:12:19

the problem with just looping it is that the rate of fire of the gun is much higher than the length of the file would permit, so that it doesn't get played fast enough to keep up with the gun. I'd really like to do it programmatically rather than creating an automatic fire sound or looping a sound... i want to play a sound for each shot fired, preferably just an instance of the same one. If I have to make multiple copies of the sound to keep up with the rate of fire, I will, but I was wondering if it's possible to do it with code.

CaseyB

09-02-2007 15:31:08

This has been asked a couple of times and I have been thinking about it and I think that the solution is to create something like a particle, something light-weight and short lived. You wouldn't be able to to move it once it's created and you would be able to "spawn" several instances of them and they would be cleaned as they die.

Grom

09-02-2007 16:54:23

is it terribly important that they don't move?

CaseyB

09-02-2007 17:01:25

My thought was that you wouldn't be able to reference each instance individually, so I guess that it could just stay with the "Producer" as it moved around, but you wouldn't be able to move each instance on it's own. But then what would happen in the case of something like a rocket? Where you, potentially want many of them and you would want to have it play the sound and have the sound move with it.

Grom

09-02-2007 19:04:38

how would I go about coding such a thing?

CaseyB

09-02-2007 19:19:39

how would I go about coding such a thing?I am not sure... That's why it hasn't made it into OgreAL yet! ;) It is one of the things that we are working out though, so bear with us. :D