I've had this problem for a few months now and its starting to do my head in.
I have an array of 32 sound channels which I cycle through to play sounds -this ensures I can cap the number of sounds that are playing at once. I used to have 16 but increased it to 32 in a failed effort to resolve this problem.
The problem seems to be with looped sounds. I have one looped sound which is allocated its own channel each time it is played, and I change the channel rate slightly depending on how many points the player scored. This also determines the length of time the sound is played for.
Occasionally, my other sounds get looped too. There is no pattern to this whatsoever - it appears to be completely random. When it happens, I get a sound effect playing over and over that should NOT be looped, and no further sounds will play.
This is my function that plays non-looped sounds
That's pretty straightforward so I won't bother to explain what its doing, except to say that maxChans is set to 32 elsewhere in my code.
The method below is where I start/stop the looping sound. I believe the problem is here somewhere. Its slightly messy just now as I'm constantly rearranging stuff in an effort to get it to work correctly.
I'm pretty much out of ideas. I'm either doing something wrong somewhere, or the BRL sound module has a problem.
[edit] Hope this post is clear. Its currently after 3am and I've been messing with this for ages tonight - brain is all over the place now.
I have an array of 32 sound channels which I cycle through to play sounds -this ensures I can cap the number of sounds that are playing at once. I used to have 16 but increased it to 32 in a failed effort to resolve this problem.
The problem seems to be with looped sounds. I have one looped sound which is allocated its own channel each time it is played, and I change the channel rate slightly depending on how many points the player scored. This also determines the length of time the sound is played for.
Occasionally, my other sounds get looped too. There is no pattern to this whatsoever - it appears to be completely random. When it happens, I get a sound effect playing over and over that should NOT be looped, and no further sounds will play.
This is my function that plays non-looped sounds
Function playSnd(hnd:TSound,rate:Float = 1,pan:Float = 0) chanPtr:+1 If chanPtr>maxChans-1 chanPtr = 0 EndIf chan[chanPtr].Stop chan[chanPtr] = Null chan[chanPtr] = New TChannel chan[chanPtr] = CueSound(hnd) SetChannelRate chan[chanPtr],rate SetChannelPan chan[chanPtr],pan ResumeChannel chan[chanPtr] End Function
That's pretty straightforward so I won't bother to explain what its doing, except to say that maxChans is set to 32 elsewhere in my code.
The method below is where I start/stop the looping sound. I believe the problem is here somewhere. Its slightly messy just now as I'm constantly rearranging stuff in an effort to get it to work correctly.
Method UpdateLevelScore() Local chanRate:Float If levelScore < levelTargetScore levelScore :+ rate If chanAddScore = Null chanAddScore = New TChannel chanAddScore = PlaySound(sndAddScore) 'AM I USING THIS RIGHT???????? chanRate = 1 SetChannelRate chanAddScore,1 EndIf If levelScore >= levelTargetScore levelScore = levelTargetScore If chanAddScore <> Null chanAddScore.Stop chanAddScore = Null EndIf EndIf EndIf If chanAddScore <> Null chanRate = 1+((Float(levelScore)/Float(winPoints))*0.3) SetChannelRate chanAddScore,chanRate EndIf End Method
I'm pretty much out of ideas. I'm either doing something wrong somewhere, or the BRL sound module has a problem.
[edit] Hope this post is clear. Its currently after 3am and I've been messing with this for ages tonight - brain is all over the place now.