Sound won't repeat until it has finished playing

Hi,

I’m making a game where every time the character taps on the screen a bullet fires.  With the following code, if I tap the screen really fast, it won’t play a new sound unless the current bullet sound has stopped.  How do I get around this?

–in the screen tap event listener

local bulletSound = audio.loadStream( “sounds/fire-bullet.wav” );

audio.play(bulletSound);

Thanks!

Are you loading the sound each time?  Normally you would load it once and then just play it whenever you need it later.   Also for short sounds audio.loadSound() is a better choice.

You have 32 channels and if your run out of channels then you will have trouble playing future sounds.  You should also make sure your bullet sound has any dead space trimmed from the start and end so the sound will play as quickly as it can, freeing up a channel.

Rob

Thanks Rob!

I edited my code to this:

local bulletSound = audio.loadSound(“sounds/fire-bullet.wav”)

–in bullet shoot function

audio.play(bulletSound,{channel=audio.findFreeChannnel(6)})

That took care of it.

Are you loading the sound each time?  Normally you would load it once and then just play it whenever you need it later.   Also for short sounds audio.loadSound() is a better choice.

You have 32 channels and if your run out of channels then you will have trouble playing future sounds.  You should also make sure your bullet sound has any dead space trimmed from the start and end so the sound will play as quickly as it can, freeing up a channel.

Rob

Thanks Rob!

I edited my code to this:

local bulletSound = audio.loadSound(“sounds/fire-bullet.wav”)

–in bullet shoot function

audio.play(bulletSound,{channel=audio.findFreeChannnel(6)})

That took care of it.