check this out, I tried to make my code more like yours (i.e. not use an array, just a global channel which I never free) and it still results in the bug:
Strict EnableOpenALAudio() SetAudioDriver("OpenAL Generic Software") 'comment this out for no crash Const MAX_CHANNELS=16 Global channels:TChannel[MAX_CHANNELS] Global CurrentChannel=0 Local sound:TSound = LoadSound("test.wav") Local Counter=0 Local total=0 Const TEST_VALUE = 256 'anything up to and including 15 will result in a sound, anything over will not. Global ch:TChannel Graphics 400,300,0 While Not KeyHit(KEY_ESCAPE) Cls Counter:+1 If Counter=1 Then If Total<TEST_VALUE Then ch=AllocChannel() ' CreateChannels() ' KillChannels() Counter=0 ElseIf total=TEST_VALUE ' CreateChannels() Play(Sound) EndIf Total:+1 EndIf DrawText Total,10,10 DrawText CurrentChannel,10,30 Flip Wend Function Play(sample:TSound) ' Local ch:TChannel=channels[CurrentChannel] ch=AllocChannel() PlaySound sample,ch ' CueSound(sample, ch) ' ResumeChannel(ch) CurrentChannel:+1 If CurrentChannel=MAX_CHANNELS Then CurrentChannel=0 End Function Function CreateChannels() For Local i=0 To MAX_CHANNELS-1 channels[i]=AllocChannel() Next End Function Function KillChannels() For Local i=0 To MAX_CHANNELS-1 StopChannel(Channels[i]) Channels[i]=Null Next End Function