3 Replies Latest reply on Feb 4, 2007 7:52 PM by cratica

    inconsistent audio playback timing

    cratica Level 1
      I'm having an issue I can't seem to resolve. I have a song (wav or mpg compressed, tried both) that plays. During it's play, I have events that occur based on how long the audio has been playing. Now, sometimes the playback events are spot on and sometimes the events are on at the beginning of the playback, then progressively get worse (timing occurs too late).

      I have preloaded the audio before any timing occurs so I don't think that is the issue. Nothing else is running in the background. There seems to be no way of re-creating the problem. It will work one time perfectly, then the next will have the progressively worse delays.

      How I time it...

      I start the audio with sound(2).play...
      I start a timer... timer = _system.milliseconds ...

      I compare current time with a list of cue times. If the cue time is less than current time based on the timer (start time of audio)
      then I trigger the event. As I said, it works spot on throughout an entire song with 400 cue points about 1/2 the time. The other half will be spot on at the beggining but by the end of the song the cued events will be about 1/2 second off (too late... 4 minute song).

      Anyone know what this problem might be?

      thank you much!
        • 1. Re: inconsistent audio playback timing
          Level 7
          Hi Cratica,

          If I'm understanding what you said, it sounds like you're monitoring the general
          movie play time and comparing that to the time of your cue points in the sound. Is
          that right? If so, that's not a good idea as there can be discrepancies between the
          two. The sound may start a little later that the 'play' time. Rather, check the
          time of the sound member itself using 'currentTime' property, e.g.:
          sound(2).currentTime

          Also, look up cue point Lingo. I have some info on this at:
          http://www.fbe.unsw.edu.au/learning/director/Lingo/tempoLingo.asp
          but notice that page needs to be updated.

          regards
          Dean

          Director Lecturer / Consultant
          http://www.fbe.unsw.edu.au/learning/director
          http://www.multimediacreative.com.au



          • 2. Re: inconsistent audio playback timing
            Level 7
            "cratica" <cratica@austin.rr.com> posted in macromedia.director.basics:

            > I start the audio with sound(2).play...
            > I start a timer... timer = _system.milliseconds ...
            >
            > I compare current time with a list of cue times. If the cue time is
            > less than current time based on the timer (start time of audio)
            > then I trigger the event.

            Rather checking the milliSeconds in a separate roll-your-own timer, why not
            check the currentTime of the sound channel itself? It returns the time in
            milliSeconds, too, and should be more accurate.

            sound(2).currentTime



            --
            Mark A. Boyd
            Keep-On-Learnin' :)
            • 3. inconsistent audio playback timing
              cratica Level 1
              Thanks guys, I tried using the .currentTime command but
              found it wasn't as accurate. Are there ways to get the .currentTime command to be as accurate as _system.milliseconds?

              For example, if you look at the output using .currentTime, it looks like this

              -- 535.0000
              -- 535.0000
              -- 535.0000
              -- 743.0000
              -- 743.0000
              -- 743.0000
              -- 743.0000
              -- 743.0000
              -- 743.0000
              -- 743.0000
              -- 987.0000
              -- 987.0000
              -- 987.0000
              -- 987.0000
              -- 987.0000
              -- 987.0000
              -- 987.0000
              -- 1230.0000
              -- 1265.0000
              -- 1265.0000
              -- 1265.0000
              -- 1265.0000
              -- 1265.0000
              -- 1265.0000
              -- 1265.0000



              If you use milliseconds, there are no jumps in the numbers, just steady, accurate time, like this...
              -- 72943634
              -- 72943671
              -- 72943707
              -- 72943742
              -- 72943778
              -- 72943814
              -- 72943851
              -- 72943886
              -- 72943922
              -- 72943960
              -- 72943996
              -- 72944032
              -- 72944067
              -- 72944102
              -- 72944137
              -- 72944172
              -- 72944207
              -- 72944242
              -- 72944278
              -- 72944314
              -- 72944349