I am experiencing strange behavior I don’t understand – please help!
My application plays a small sample file many times. The sample is only about 0.25 secs long and is played randomly, about once every half second. Sometimes, it happens that the sample is played several times at once. That’s all within the expected behavior.
Now the funny thing is: After a while (after between 20 and 50 secs usually), my programm keeps calling fmod->playSound(…) but I don’t hear any sound. This happens both when I am using the iPhone Simulator and when I run the program on my iPod Touch.
Do you have any ideas why this may happen?
May it have to do with memory filling up, but then: Why should it? (I am just guessing)
Is there a way I can make FmodEx print more debug output?
thank you, Johannes
- jjh asked 9 years ago
I thought that maybe the above problem would not occur if I started a fresh, new, very very simple project.
Alas no! – I still get the same behavior.
Could someone please have a look at this sample application?
It’s very simple and won’t take much time to look at, I promise!
thank you, Johannes
ok, i did look at the code, but since I dont fully understand how Objective C works, nor do I have a way to test the code, i cant fully help you. However, i did notice something a little odd. You have your channel handle as a local variable.
just from what I gather by looking at the code, you initialized fmod with 100 for max channels. When your playsound method is called, that same channel is overwritten. perhaps if you make the channel a global variable instead it would work better. I noticed you said that sometimes there are many that play at the same time, so perhaps that channel handle is being overwritten in memory and getting screwed up.
- nci answered 9 years ago
Firstly I notice you are launching a new thread for your sound calls, FMOD is not thread safe, I highly recommend you remove that method of playing sounds.
The reason your sound stops playing is because you have used the maximum number of software channels (by default 64) and you are not updating FMOD so it can free them.
If you take a look at some of the FMOD examples you will see the desired method of using FMOD is via a timer. The time is invoked from the main thread and gives you a good place to call System::update(), you can also perform any time sensitive logic in there to play sounds, or you can have sounds fired off by user interaction.
The key here is to remember to call System::update() regularly.
Please login first to submit.