Anyone had any experience with mixing sound channels in games? What I mean is, say two enemies blow up at once. If you play two explosions it's too noisy so you decide OK, I'll just play one, fine. But what if the enemies blow up one slightly after the other. If you only have a single channel you have a choice of let the original sound continue playing or cut if off and play the new explosion (this normally sounds pretty bad, makes clicks etc). So if you have multiple channels and multiple explosions occuring at different times, it still gets too noisy.
Furthermore, say the user presses shoot at the exact frame that an explosion occurs and when both samples play at once, they mix and produce a distorted crackle because they are overloading the soundcard due to getting square wave forums at max volume (I think). Does anyone know what I mean? I can duplicate this very clearly by playing two sound effects I have at once.
Now, in a music program this can occur too, so you either find the correct volume levels for all channels where it doesn't happen or you bung on a Compressor DSP which looks to see when a sound is peaking and then reduces it to keep it all at max volume but not making flat peaks (don't know the technical term form this).
So anyway, seeing as BMax or BPlus doesn't have a built in compressor, I'll have to try some kind of dynamic volume balancing. What I'm thinking is when the 2nd sample plays, play it at 50% vol and reduce the original one to 50% as well. Would this mean the total is 100% or doesn't it work like that? In fact would it sound funny having a sample suddenly half volume? Likewise 3 samples = 33% each and so on. I just worried that say 10 samples = 10% each and it could sound crap. Really for most samples you only want to reduce the first bit which is loudest, like a snare drum with reverb or something, and then you could boost the level back up for the last bit which is quieter, but how to do that I've no idea. It would have to be pretty low level unless I made a volume ramp for each sample that get's applied each frame based on delta timing or something...
Anyway thought I'd bandy this idea around and see what people have to say :-)
[edit] please test this (pressing 3 is noisy and crap (distorted/crackly) on my PC):
http://www.greyaliengames.com/misc/soundtest.zip (587kb)
Press keys 1-4. 1=A, 2=B, 3=A+B(100% vol each), 4=A+B(50% vol each). Esc = Exit
here's the code:
Furthermore, say the user presses shoot at the exact frame that an explosion occurs and when both samples play at once, they mix and produce a distorted crackle because they are overloading the soundcard due to getting square wave forums at max volume (I think). Does anyone know what I mean? I can duplicate this very clearly by playing two sound effects I have at once.
Now, in a music program this can occur too, so you either find the correct volume levels for all channels where it doesn't happen or you bung on a Compressor DSP which looks to see when a sound is peaking and then reduces it to keep it all at max volume but not making flat peaks (don't know the technical term form this).
So anyway, seeing as BMax or BPlus doesn't have a built in compressor, I'll have to try some kind of dynamic volume balancing. What I'm thinking is when the 2nd sample plays, play it at 50% vol and reduce the original one to 50% as well. Would this mean the total is 100% or doesn't it work like that? In fact would it sound funny having a sample suddenly half volume? Likewise 3 samples = 33% each and so on. I just worried that say 10 samples = 10% each and it could sound crap. Really for most samples you only want to reduce the first bit which is loudest, like a snare drum with reverb or something, and then you could boost the level back up for the last bit which is quieter, but how to do that I've no idea. It would have to be pretty low level unless I made a volume ramp for each sample that get's applied each frame based on delta timing or something...
Anyway thought I'd bandy this idea around and see what people have to say :-)
[edit] please test this (pressing 3 is noisy and crap (distorted/crackly) on my PC):
http://www.greyaliengames.com/misc/soundtest.zip (587kb)
Press keys 1-4. 1=A, 2=B, 3=A+B(100% vol each), 4=A+B(50% vol each). Esc = Exit
here's the code:
Strict Global a:TSound = LoadSound("match.wav") Global b:TSound = LoadSound("land.wav") Global c:TChannel = AllocChannel() Global d:TChannel = AllocChannel() Graphics 640,480,0 While Not KeyHit(Key_ESCAPE) If KeyHit(KEY_1) Then PlayA(1) If KeyHit(KEY_2) Then PlayB(1) If KeyHit(KEY_3) Then PlayA(1) PlayB(1) EndIf If KeyHit(KEY_4) Then PlayA(0.5) PlayB(0.5) EndIf Wend Function PlayA(vol#) a.Cue(c) c.SetVolume(vol) c.SetPaused(0) End Function Function PlayB(vol#) b.Cue(d) d.SetVolume(vol) d.SetPaused(0) End Function