Audio stopped while playing the game

BlitzMax Forums/BlitzMax Programming/Audio stopped while playing the game

Keith Gilbert(Posted 2009) [#1]
Hi,
we have game playing application which we have many modules. some of the modules having audio instructions. While playing the game after some time the audio was stopped. if we close the application and it works fine.

Any one know the reason please reply.

Thanks


markcw(Posted 2009) [#2]
Hi Keith, you really need to provide some specifications.

What audio module/s does the app use, what version of Max was it built with and what platform/s is it on?


TaskMaster(Posted 2009) [#3]
Agreed, without any hints, it could be just about anything. Maybe you are not releasing your channels and you are running out of them?


theHand(Posted 2009) [#4]
Hi Keith, I am not a moderator and have no formal standing at BRL.

Keith, in addition to what Mark said, you should provide either the source in full or the section of your program that you feel contains the cause of the problem. This will help you get an answer to your question more quickly.


markcw(Posted 2009) [#5]
Wait a minute, who said anything about moderators?


theHand(Posted 2009) [#6]
No one, I just didn't want him to think that I worked for BRL, or volunteered as an admin for them.


Nate the Great(Posted 2009) [#7]
No one, I just didn't want him to think that I worked for BRL, or volunteered as an admin for them.




why would he think that?


markcw(Posted 2009) [#8]
Maybe he's just a bit daft. :)


Grey Alien(Posted 2009) [#9]
I've heard of this on both PC and Mac with older versions of Bmax. Not sure if it's fixed yet. Some sound issues were fixed with V1.36 though.


Keith Gilbert(Posted 2009) [#10]
We are using following method every time once one level game is complete and once again starting the game but its stopping audio in one stage not regularly.
' -------------------------------------------
' Disable Monitor
' -------------------------------------------
Method Disable()

'If mDebugMode = True Then ..
'Print "Monitor:Disable()"

mEnabled = False
mInitialized = False

If ChannelPlaying(mSoundChannel) Then
StopChannel(mSoundChannel)
mSoundChannel = AllocChannel()
EndIf


If ChannelPlaying(mMetronomeChannel) Then
StopChannel(mMetronomeChannel)
mMetronomeChannel = AllocChannel()
EndIf


EndMethod


degac(Posted 2009) [#11]
Why do you use StopChannel and not PauseChannel?
StopChannel is equivalent to KillChannel, maybe the process to create/delete causes your problem.


Grey Alien(Posted 2009) [#12]
Stopping the channel the reallocating works, I use it in my framework.


Keith Gilbert(Posted 2009) [#13]
Any other reason other than StopChannel which causes the auido to go off?


Jesse(Posted 2009) [#14]

Stopping the channel the reallocating works, I use it in my framework.


I have a volume control for music and sound fx in my game. When I use stop channel and I restart it, the volume controll does not work. It auto resets to full volume and I can't adjust it. I have to use PauseChannel and that works fine.


Grey Alien(Posted 2009) [#15]
You just have to reapply the volume again to the new channel (the reference to the old channel will be invalid) when you start it and that will work (works for me). I don't immediately play the sound I use CueSound (I think that's the command), set the volume, the resume it.


Keith Gilbert(Posted 2009) [#16]
CueSound allows you to setup various audio channel states such as volume, pan, depth and rate before a sound actually starts playing.

I commendted out the StopChannel(mMetronomeChannel) line still i am facing the same problem.

It works fine for first few minutes (10-30) after that it automatically stops the audio. If I close the application and restart its works fine again!

What may be the reason??


Keith Gilbert(Posted 2009) [#17]
Any Other command or function which may cuase to stop the audio?

While debugging the statement
Print "PlaySound(mThreeSound, mMetronomeChannel) Executed"

is print the message but audio was off.



If ChannelPlaying(mMetronomeChannel) Then
StopChannel(mMetronomeChannel)
Print " StopChannel(mMetronomeChannel) Executed In Countdown Three"
mMetronomeChannel = AllocChannel()
SetChannelVolume mMetronomeChannel, 1
EndIf

PlaySound(mThreeSound, mMetronomeChannel)
Print "PlaySound(mThreeSound, mMetronomeChannel) Executed"


BlitzSupport(Posted 2009) [#18]
Are you specifying the channel variables as being of type TChannel? I had similar problems in the BlitzMax RockOut sample (which are still there), and it eventually causes random silence or crashing. I only figured out about a year ago that this was the cause of my mystery crashes, ie. the channel objects weren't being garbage-collected and the channels weren't freed as a result.

Doing this sort of thing to play each sound is what stopped the problems for me:

' Set up channel...

play:TChannel = CueSound (beep)

SetChannelVolume play, Game_Volume
SetChannelPan play, pan

' Play sound...

ResumeChannel play

' This is probably unnecessary, since assigning a new channel to play:TChannel via CueSound should free up the previous channel assigned to it...

play = Null



Grey Alien(Posted 2009) [#19]
Good point. Always code with superstrict on to enforce stuff like that.


Keith Gilbert(Posted 2009) [#20]
I made some changes in the code, Dramatically it looks fixed now still testing is on.



Thanks to all for valuable replies!