Sound Channel Problem

Blitz3D Forums/Blitz3D Beginners Area/Sound Channel Problem

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I use this sort of method - ensures that no more than 5 explosions (0-4) can be playing at once. If it reaches a point where explosions are playing on all 5 'channels' (elements of the Explosion array), then the oldest one is stopped. Funny, took longer to explain it than it did to write the code that does it. :)
Dim Explosion%(4)
Global ExplosionPtr%

Function PlayExplosion()
  ExplosionPtr = ExplosionPtr + 1
  If ExplosionPtr > 4 Then ExplosionPtr = 0
  If ChannelPlaying(Explosion(ExplosionPtr))
    StopChannel Explosion(ExplosionPtr)
  EndIf
  Explosion(ExplosionPtr) = PlaySound(sndExplosion)
End Function