3 Replies Latest reply on Sep 5, 2007 3:22 AM by johnAq

    Sound Freeze during AI processing

    Sword Saint
      I'm having problems with the background music freezing and stuttering when heavy recursive operations or even large matrix data processing are being performed on Macs. I am using MX 2004. It doesn't happen at all on the Windows projector version where I have the sound device set to direct sound. I can get rid of some of it by strategically placing updatestage commands in nested loops etc. but besides being very inelegant and slowing everything down it also doesn't solve the problem completely. I have tried using QuickTime running seperately in a sprite but that does not work either. I found a post by a developer from a couple years back where he was making a casual game that had some involved AI routines and he was getting the same behavior with the back ground music. He didn't have a solution besides update stage.

      Has anybody else encountered this? Any solutions? I hope the Director 11 team is aware of this and can fix this.
        • 1. Re: Sound Freeze during AI processing
          James Newton, ACP Level 3
          I assume that your lengthy AI routines need to be run once at the beginning of a section, rather than repetitively on each frame. If this is the case, then you may be able to spread the process over several frames.

          Instead of using a repeat loop, you could use an "on enterFrame()" to process the data. This will mean using a Behavior or an instance of a Parent script, so that you can store the current value of the variables as properties.

          If you are unfamiliar with using script instances with properties, I can describe the steps in more detail.

          You might like to look at the example at http://nonlinear.openspark.com/tips/other/playDone/. This shows you how a lengthy (but in this case meaningless) process can be treated asynchronousely on stepFrame().
          • 2. Sound Freeze during AI processing
            Sword Saint Level 1
            Hey Thanks for the reply. Yes the AI routine is usually run just once but there are many of them. The game is here http://www.crypticcomet.com I have a goal based AI running for a turn based strategy game. The sprites for the UI are just puppeted as needed and the movie runs on a single frame. What is really exasperating is that it works just fine in Windows. Never a stutter. You can process long recursive operations and everything is just fine. On the Mac the background music stutters and freezes. Like I said the updatestage placed strategically can eliminate some of this but not all. What is difference in the way the sound is handled that allows the windows version to handle this smoothly? At this point I can't rewrite the whole turn architecture. Thanks for your help. Don't mean to be complaining.
            • 3. Re: Sound Freeze during AI processing
              johnAq Level 1
              Just a thought: updateStage 'frees up' Director to update sound & stage etc. In the same way there is a little trick explained in this article that frees it up system resources.


              Buddy API also has a similar sleep function to that described in the article. I guess you'd have to use it frequently in the same way as updateStage, but it may be less off a slowdown, or free up the additional resources required