Playing sounds correctly and other stuff

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
todor943
Posts: 3
Joined: Sat Sep 12, 2009 4:03 pm

Playing sounds correctly and other stuff

Post by todor943 »

Hello guys, I don't know if i can include and IrrIlang problem in an Irrlicht forum, but I reckon most of you use it anyway :)

So my problem is how do I time the sounds correctly so that they do not overlap. Some of the sounds like "steps" are fine because they are only the main sound. Others like the shooting sound include reverberations, echoes and other stuff recorded into the sound. These are the real problem. The way I'm checking whether to play a sound isn't working very well. As the button is held down the sound plays once, then pauses, plays several times, pauses again and so on. Also feel free for any other extra advice you can give me, as I need all I can get.

Here's the pastebin of my code http://pastebin.com/f3dd9a7f1

As I said if there is anything in the code that would work better some other way, tell me.

Cheers
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

Code: Select all

    if(now%15 == 0)

            {

                sengine->play2D(shots);

                once = 0;

            }

This is probably why it's skipping so much. You're probably doing it to do it every 15 ms? Well what if now goes from 14 to 16? You just skipped what would've given you a 0. So try

Code: Select all

int timer = 0;
...
if (now >= timer) {
       sengine->play2D(shots);
       once = 0;
       timer = now+15;
}
todor943
Posts: 3
Joined: Sat Sep 12, 2009 4:03 pm

Post by todor943 »

Thanks, worked like a charm!
Post Reply