7 Replies Latest reply on Jan 24, 2007 11:51 AM by abeall

    Overlapping sounds interferring with each other

    megaresp
      Using Flash 8 Pro (free trial). I haven't downloaded any updates (help > about shows version 8.0).

      I have 2 weeks experience with Flash, and a week with Actionscript, so I'm new to this. But I have plenty of experience with php and javascript.

      I have two sounds. Both are music tracks imported into the library in .wav format (I get same result with mp3). The tracks are assigned in Actionscript as follows...

      var introMusic:Sound=new Sound();
      introMusic.attachSound("intro_music");
      introMusic.start(0,1);

      var presentMusic:Sound=new Sound();
      presentMusic.attachSound("present_music");

      I get presentMusic (the second sound) to start just as introMusic is fading out. NOTE: The fade is actually in the music. I'm not using flash to fade.

      So my goal is to have the sounds to overlap, with introMusic going out as presentMusic comes in. A radio DJ may do the same thing, start up the next track just as the previous one ends (fades away).

      I can do what I want in Actionscript easily enough. The script works, but when presentMusic is kicked off the sound goes haywire.

      There's massive distortion, fuzziness, and it sounds like the tempo has changed.

      Curiously, when I have the script start both sounds at the same time...it works just fine (i.e. two distinct tracks are playing normally)!

      I've been told that Flash is able to overlap sounds that start at different times, so I can only assume I've missed something. Does anybody have an answer/suggestion?
        • 1. Re: Overlapping sounds interferring with each other
          abeall Level 3
          That's strange. I'd be personally curious to see the .fla and do some tinkering. One suggestion I would make is to use MovieClips as holders for your Sound. The behavior of the Sound object has always seemed a bit odd to me, but try something like this:
          createEmptyMovieClip("introMusic_mc",getNextHighestDepth());
          var introMusic:Sound=new Sound(introMusic_mc);
          introMusic.attachSound("intro_music");
          introMusic.start(0,1);

          createEmptyMovieClip("presentMusic_mc",getNextHighestDepth());
          var presentMusic:Sound=new Sound(presentMusic_mc);
          presentMusic.attachSound("present_music");

          It doesn't make much sense, but it might help to seperate them "more" like that.
          • 2. Re: Overlapping sounds interferring with each other
            kglad Adobe Community Professional & MVP
            each timeline can have at most one sound object defined and still allow independent control of each. you're not specifying a timeline in your new Sound() declaration, so flash assumes you're using the current timeline for each which is equivalent to new Sound(this).

            to remedy create another movieclip (createEmptyMovieClip() will work) and use that movieclip instance name (say, newMC) in the new Sound(newMC) statement.
            • 3. Overlapping sounds interferring with each other
              megaresp Level 1
              quote:

              Originally posted by abeall
              createEmptyMovieClip("introMusic_mc",getNextHighestDepth());
              var introMusic:Sound=new Sound(introMusic_mc);
              introMusic.attachSound("intro_music");
              introMusic.start(0,1);

              createEmptyMovieClip("presentMusic_mc",getNextHighestDepth());
              var presentMusic:Sound=new Sound(presentMusic_mc);
              presentMusic.attachSound("present_music");

              I've pasted this into the fla, but get the same result.

              How would I send you the fla?
              • 4. Re: Overlapping sounds interferring with each other
                megaresp Level 1
                quote:

                Originally posted by: kglad
                to remedy create another movieclip (createEmptyMovieClip() will work) and use that movieclip instance name (say, newMC) in the new Sound(newMC) statement.

                I pasted the code in the previous reply into my document, which uses createEmptyMovieClip(), but this hasn't solved the problem.

                It's looking like I'm going to have to edit the music tracks so the first beats of the second track are in the first track...which means using .wav.

                I've looked for this problem in forums and on the web, and can't believe I'm the first to discover it. What's more, people seem to think it shouldn't be happening. I'm beginning to wonder if my PC and/or sound card is somehow the problem here. Does that seem likely to you? Especially given the fact that it works if I start that tracks playing at the same time.
                • 5. Re: Overlapping sounds interferring with each other
                  megaresp Level 1
                  Thank you for your help.

                  I've now discovered the cause of the problem, and it was my own fault.

                  In effect, I was starting the sound file over and over again at 96 frames per second. I hadn't added a simple flag to make sure I only issued presentMusic.start(0,1) once.

                  Everything worked just fine once I did that.

                  I am very embarrased about this stupid mistake, and apologize for the time I've taken.
                  • 6. Re: Overlapping sounds interferring with each other
                    kglad Adobe Community Professional & MVP
                    you're welcome. and i'm pretty sure i hold the record for most stupid mistakes using actionscript.
                    • 7. Re: Overlapping sounds interferring with each other
                      abeall Level 3
                      at this point, there are probably quite a few records you hold with actionscript ;-)