Some audio questions

Hi,

I just created the background music and some samples for my game. I have a few problems/questions though.

The soundtrack currently is just a 10 second loop. I have it set up so it starts in the menu and keeps on looping (by preserving the gameobject and audio listener throughout scenes). If I use compressed audio though, it doesn’t loop properly, and during the loading of my game scene, it briefly stops playing. But if I use uncompressed audio, it will be a bit bigger (obviously), and it also plays if the user has his own music playing. So neither option is ideal. Any suggestions? Can I detect if the user is playing his own music?

My second problem is with the sounds. I have some sounds that are about one or two seconds long that play whener you grab a bonus. But sometimes you can grab multiple bonuses in a row, resulting in some overlap of the sounds, which can get too loud if the volume of the device is turned up all the way. Any techniques on how to deal with this? Turning down the volume on my samples would be one option. Or maybe stopping previous samples, but I’m not sure that would sound good, the sounds would stop too abruptly.

Thanks!

If you don’t want to compress it, a 10 second file shouldn’t be very big, and you can always have a mute setting if your users want to play their own audio. A bit of advice though, you might want to consider a longer tune… you’ll likely drive folks crazy with a 10 second background song! :smile:

As for the bonus sounds, you can detect if the sound is already playing:

if (!audio.isPlaying) 
     //do something

And choose to play the sound only if it’s not already playing, or maybe change the pitch, etc.

Thanks.

The 20 second loop is pretty low tempo and chill, so it doesn’t annoy too much. However, I think I might try to turn it into a full track, and go with the compression. If it has an intro and an ending, it won’t matter if it doesn’t loop properly, and I’ll have the other advantages of compressed audio.

As for the sound overlap, it’s not an option to not play the new sound. But I think I’ll always store the previous playing sound somewhere, and if a new sound is playing, I’ll turn down the volume of the other one to 50% or less. It’s worth a try.

only a single compressed track can be used at a time. Thats potentially why looping won’t work as well at least if you wanted it without a 0.5s break to “reload”

So if you want multiple tracks, smooth fading and alike, uncompressed sound files are the way to go