Advice on Multiple Sounds

BlitzPlus Forums/BlitzPlus Programming/Advice on Multiple Sounds

Grey Alien(Posted 2005) [#1]
I have wrestled with this before and thought it is about time for a topic.

In my (B+) game there are many aliens which you shoot. If several explode at once or very soon after each other I have several options:

a) play every explosion, not stopping any channels, BUT this can result in much too loud noise as many samples play at once.

b) only have one channel and use Stopchannel before each new explosion noise BUT when many explode shortly after each other the stopchannel causes a horrid clicking as the sample cuts and restarts.

c) a hybrid of a and b such as having 3 channels that you rotate and you do you the stop channel method. This is better but there is still a horrid clicking.

d) check to see if the channel is playing and if so, don't start a new explosion noise (bit lame?)

e) write some code to fade a channel in a few millisecs instead of stopping it dead in a hope to avoid the clicking sound. Could be a fag.

f) Try a different sample I suppose to avoid clicking or it being too loud. Could the problem be that I am using an old 8 bit sample? Mind you I have had this problem with other samples that I sure are 16 bit.

How have you done it in your games? Any advice is very welcome, thanks in advance.

On a side note, I noticed that when blitz plays modules, certain tracking techniques cause it to make clicks such as the cut channel (by using caps lock key in FT2). But the mods play fine in the tracker and other tracking utilities. Does this mean that the blitz plus mod player (and sample playing code) is inferior?


CS_TBL(Posted 2005) [#2]
On that last one: I know that Impulse Trackter for example uses fast volume-ramps to fade-in samples (50 samples orso).. dunno about note-off's, but since I use NNA-fade always, a sample fades-out anyway here..


also consider:

g) use channels as you need, but to prevent loudness, keep track of the number of channels you're using and adjust the volumes of all channels. This is like having a voice-duck on radio (music gets played softer when the DJ talks).


Grey Alien(Posted 2005) [#3]
ok thanks. Whats NNA-fade?

I had considered g) but forgot to list it. Would you recommend a 50% reduction if only one sound is currently playing? What about if 2 sounds are playing (both already at 50%), play new one at 33% and reduce other two to 33%? Will this reduction of volume sound odd if a sample has already started played and suddenly it is at half vol?


CS_TBL(Posted 2005) [#4]
oh uh, NNA is New Note Action .. introduced in Impulse Tracker. It means that you work with visual and internal channels (cycling!). With the NNA you define what should happen when a new note on the same visual channel occurs. In IT you can choose between: note cut, continue, note fade, note off (continues with the envelope).


And regarding levels: one sound = 100%, 2 sounds together = 100%, 3 sounds together = 100% .. etc.
So, volume_per_sound = 100%/amount_of_sounds..

makes sense to me at least ^_^


anyway.. how many sfx at the same time were you having in mind anyway?

I'd simply add them all together, and give the user 2 controllers: sfx-level and music-level.
Some gain could be made from processing the sfx. If you get rid of the low-end you've some more headroom to prevent clipping. If you get rid of the mid-area (around 3k) then you save on the area on which the human ear is most sensitive.. chances are that you can add more sfx together then without irritating the user.

So in the end: reconsider option (a)


Grey Alien(Posted 2005) [#5]
I get it, you use NNA - note fade for smoother cut off, thats what I was talking about coding.

Yeah, my example of 2 @ 50% and 3 @ 33% yields a total of 100%.

I basically may need to play loads of samples at once, image a powerful weapon killing multiple enemies at same time or slightly after each other (millisecs apart), this could result in 10+ sounds which makes a horrid clipped loud noise.

So filtering the sample could be the key, unless I want to write volume ramping code (what a fag).

Anyone else got anything to add?


Grey Alien(Posted 2005) [#6]
I just tried an option where I cycle 3 channels for explosions and test if the current channel is still playing, and if so I don't play a new explosion. This means that explosions are not played for every death but when there are so many you don't really notice. Could be an answer.