Sound problem

BlitzMax Forums/BlitzMax Programming/Sound problem

I get the same but I reckon it's because you're allocating a new channel everytime you do the PlaySound and because there's only a finite number of channels available you'll get some re-use eventually.

This works but note that it'll cut of the existing sound when a new sound is played (non polyphonic).
'Tap '2' a few times, the sound plays fine. Tap '1' a few times to play the same sound with a random
'rate, then tap '2' again, the pitch fluctuates (it shouldn't?)

Global laserfire1:TSound = LoadSound("yoursound.wav")
Global chan1:TChannel = AllocChannel()
Global chan2:TChannel = AllocChannel()

Graphics 800,600,0
Repeat
	If KeyHit(KEY_1)
		PlaySound(laserfire1,chan1)
		SetChannelRate chan1,Rnd(.1,1.9)
	End If
	
	If KeyHit(KEY_2)
		PlaySound(laserfire1,chan2)
	End If
	
	Flip
	Delay 5
Until KeyHit(KEY_ESCAPE)