11 Replies Latest reply on Mar 14, 2007 1:16 PM by cratica

    Audio playback speed is inconsistent

    cratica Level 1
      I am playing audio files (swa) and have events triggered as the audio file is played. All the events occur on time and are consistent with each other. However, I am realizing that the sound file does not always play back at the same speed. It is not something you can hear with your ears, but you can see the effects when things are supposed to be timed at exact instances.

      For example, say I had a timer that displayed text that started at 60, then counted down every seconds, 59, 58, 57 etc.
      And now let's say I have a compressed audio file that has a voice that is recorded to say 60, 59, 58 in 1 second increments.

      When this movie is played, at the beginning, the audio and the text will line up perfectly. (audio and text are syncrhonized)
      However, the longer the movie is played, the more the audio is off synch. The audio plays a little faster than it should so by the time the timer reaches 1, it may be off by a 1/4 of a second.

      Another problem is that sometimes it does this and sometimes it stays perfectly in synch. Absolutely no changes to the code.

      So, what would cause an audio file to playback at slightly different speeds (either perfect as it should or slightly faster than it should, accumulating an error of approximately 1/4 second a minute.

      I thought it might be the fact that a compressed file might have errors in it that accumulate. Unfortunately since it sometimes plays back perfectly, that may rule that theory out.

      Any thoughts? (and please don't say to simply link the events to a cue point or file, see my other posts about that! :) )
        • 1. Re: Audio playback speed is inconsistent
          cratica Level 1
          WOW! That's all I can say right now.

          In an attempt to get a grip on this situation and understand more about what it's doing, I loaded a song file into windows media player and started it at the same time the same song is playing from within Director. They played exactly the same and so did the synched artwork in director. Everything synched up perfectly. If I don't play the windows media file, the song within Director plays slightly faster thus making the timed artwork off synch (the longer it's played, the more off synch it becomes)

          Clearly, there is something that happens that is making Director understand the proper playback speed if windows media player is already running. If it is not, then it will play it incorrectly. (most of the time, occasionaly it will play it correctly)

          Does anyone with audio understanding know how to get around this bug in Director? Is there a way to initialeze the audio engine or tell it at what exact speed to play at?
          • 2. Re: Audio playback speed is inconsistent
            johnAq Level 1
            How are you trying to synchronise the vision & audio? What are the 'events triggered'?

            From many years of working with Director I would suggest that it is much more likely that the vision is varying, rather than the audio. Director vision is rendered in real-time and frame rates are more of a target rate (and a rough one at that).

            If you are using waits or frame rates to try and sync, don't. You should be using cue points or lingo. These will look at the current time of the audio as it is playing, regardless of speed and allow you trigger events from that. I've used Lingo to sync video and audio many time with excellent, reproduceable results.


            • 3. Re: Audio playback speed is inconsistent
              cratica Level 1
              Yes, I am using lingo and cue points. That most definately is not the problem, nor is it the events or artwork that is getting out of synch. It is the audio file that is playing at different rates. I can change the playback rate by changing the compression of the mpg or swa or avi or wav (I have tried them all at various rates, bit depths, etc). This changes the duration of the song file, albiet very little, but enough to make it unusable for my needs. This is the problem. However, Director plays the same audio file sometimes at the correct speed and sometimes slightly too fast. I can force it to play the correct speed by opening windows media player and have that running in the background at the same time. if it's playing the same file, and I then play the song in Director, the song will be played back correctly and all events are synchronized.

              The differences are not something the human ear can detect it is only apparent when you have many events cued based on milliseconds over a period of several minutes (a song) (I'm trying to display lyrics to a song as it is sung)

              • 4. Re: Audio playback speed is inconsistent
                cratica Level 1
                I can also make the audio file (song) play slightly slower than the events by using a lower compressions/bit rate. I can then make it play perfect by simply opening the same song in windows media player and having it run in the background. Very, very strange. So either way, whether the file is compressed at a high rate or slow rate and plays slightly faster or slower than it should, it will play perfectly if the same file is first opened, then played simultaneously with the media player.

                I can also sometimes get the game to play the song file correctly if I preload the song and play it once just before I start the game. Unfortunately, that method is not consistent either.

                This probably is totally crazy but it is MOST definately the audio file playing at different speeds.
                • 5. Re: Audio playback speed is inconsistent
                  johnAq Level 1
                  Can you post a test movie?

                  • 6. Re: Audio playback speed is inconsistent
                    cratica Level 1
                    unfortunately not since my movie is about 90 mb at the moment. It's easy enough to try though, just record an audio file with yourself saying the seconds every so often (such as 1, 5, 10, 15...) for about 3 minutes. Then add cue points at those same points. In Director, use lingo to display anything (text, graphic, etc...) on cuepassed.
                    • 7. Audio playback speed is inconsistent
                      cratica Level 1
                      I'm fairly certain it has something to do with anomalies during initial decompression. It somehow determines a rate at initial playback and then sticks with it. It's not inconsistent in that the speed varies during playback, it is inconsistent at which speed it chooses to playback at. In other words, I can see within the first 5 seconds whether it is going to be spot on or whether it's going be off. When it's off, it's always off by the same amount. That much is consistent.

                      Cue points are not arbitrary but compression/decompression apparently can have errors and nuances. When using the file in windows media first/simulaneously, those errors or nuances don't exist. It's seems to be an innaccuracy in the way Director handles compressed audio files as it initializes the playback of an audio file.

                      I have tried embedding the sound file (internal cast) as well as a linked cast and also playing the file from the hard drive. I have tried using puppetsound and sound.play(). No difference.

                      There has to be a work around otherwise 6 months of work is shot.
                      • 8. Re: Audio playback speed is inconsistent
                        johnAq Level 1
                        So are you saying that the file doesn't actually vary in speed but that there seems to be an offset appearing intermittently?

                        Are you using a script for cuepoint management or the tempo channel? What if you just created a simple script that has a simple put statement in an on cuePassed handler?

                        Are you going to different markers on the cues. What is actually being triggered?


                        • 9. Re: Audio playback speed is inconsistent
                          cratica Level 1
                          I really don't know how else to explain it.

                          The offset is because of the song file being played at the incorrect speed. At first there is no offset, everything lines up perfectly when the song starts. As the song plays, the difference becomes more and more apparent.

                          lyrics are being cued. There is a cue point for every word in a song. The cue points are placed by sound forge. I tried embedding them in the song file (see other post about all the different options I have tried here) and using the cuePassed function as well as the current method of exporting the cue points to a file that Director reads. Doesn't matter. All that stuff doesn't matter if the song is actually played back at 2 different speeds.
                          • 10. Re: Audio playback speed is inconsistent
                            johnAq Level 1
                            I understand. What are you using to playback the swa - Import, or Insert? Have you tried other audio formats?

                            If you want to email me directly I can give you an address to upload a test, and I'd be willing to look at it.


                            • 11. Re: Audio playback speed is inconsistent
                              cratica Level 1
                              Thanks John, that's considerate of you.

                              However, at 6am this morning I determined what the problem is. Compression. When a file is compressed it will play back slightly differently (slightly faster) When I added cue points, I added it to the master file (compressed but not as much as the final mp3 file). When the file is compressed, the cue points apparently don't change, they keep their static numbers while the actual audio file itself will change a bit, thus introducing small errors that compound themselves the longer the file is. I edited the cue points using the final mp3 file and now everything lines up perfecty in synch.

                              The only question I still have is why did Director play the game perfectly synched up when windows media file had the same song opened in the background? Why did it sometimes play it perfectly even with nothing else running except Director? I have no clue but as long as it plays correctly now, that's all I'm concerned about.

                              For those adding cue points, please remember to add them to the actual file you will use and don't try to recompress it or you will have timing errors.

                              Hope this helps future users....