Sound Channel Issue?

BlitzMax Forums/BlitzMax Programming/Sound Channel Issue?

Sean Doherty(Posted 2007) [#1]
I seem to be having problems freeing sound channels in 1.24? Once I reach 4092 allocated sound channels I can no longer allocate any additional channels.

The following code seems like it is being called:

Local pTChannel:TChannel
		For pTChannel = EachIn g_TChannelList
			
			If (pTChannel.Playing() = False)   

				'Print "Removing"
				StopChannel(pTChannel) 
				g_TChannelList.Remove(pTChannel)
				pTChannel = Null
				

			End If

		Next


Does anyone know if there is a bug?

Thanks


Tachyon(Posted 2007) [#2]
You should post your problem here.


tonyg(Posted 2007) [#3]
Don't you ask this every 6 months or so.
I thought somebody determined the number of soundchannels was dictated by the sound card. Most people create an array of 32 and reuse them.


skidracer(Posted 2007) [#4]
Hi Sean, please try syncmods for fix.


Sean Doherty(Posted 2007) [#5]
Syncmod didn't fix the issue. Thanks


skidracer(Posted 2007) [#6]
FreeAudio is designed for use with 4096 allocated channels, however it internally recycles the channels so the following is possible, replacing the delay 1 with a simple PollSystem giving interesting results indeed, no crash but.
SetAudioDriver "FreeAudio"

sound=LoadSound ("shoot.wav")
While True 
	PlaySound sound
	Delay 1
Wend


It isn't going to however work for people who want 4096+ allocated channels or who keep their own references to TSound objects or disable garbage collection. There may be an issue with references with freeaudioaudio, i need to double check but if you could post some code that helps illustrate the problem it would be really helpful.

There are undocumented limits in BlitzMax, just like timers, I see sound drivers as capable of running out of channels so I think people need to handle a null result from an AllocChannel or PlaySound. Most games I would hope allocate a static set of 64 or so channels for their looping samples and then just need to be sure they don't retain channel handles from PlaySound or AllocChannel causing them to not recycle correctly on the driver side.


Sean Doherty(Posted 2007) [#7]
There is some code posted above. I'm only using a handful of channels at a time. The code above is called every frame; it checked to see if the channel is playing and frees up the channel. Everything use to work fine, so it would seen StopChannel is not freeing up the channel?

Thanks


Sean Doherty(Posted 2007) [#8]
Seems to be freeing channels now! Thanks