2 Replies Latest reply on Jun 11, 2008 12:43 AM by Mylenium

    Use an expression to trigger a sound file?

      I have a comp with many layers. At the beginning of each layer, I want to play an AIFF file (the same one for every layer).

      Rather than adding the AIFF asset to the project over and over, is there a way to add the sound file to the comp once, and then add an expression to each layer to play that sound at the layer's in point?
        • 1. Re: Use an expression to trigger a sound file?
          A. Cobb Level 3
          Try enabling Time Remapping on the audio layer and apply the following expression:

          > firstLayer = thisComp.layer("Medium Yellow Solid 2");
          lastLayer = thisComp.layer("Medium Yellow Solid 3");
          recentLayer = firstLayer;
          for(i = firstLayer.index; i <= lastLayer.index; i++){
          currentLayer = thisComp.layer(i);
          timeDiff = time - currentLayer.inPoint;
          if(timeDiff >= 0 && currentLayer.inPoint > recentLayer.inPoint) recentLayer = currentLayer;
          }
          time - recentLayer.inPoint

          Substitute the names of the first and last layers you want to trigger the sound in the first two lines.

          It might be necessary to put a similar expression on the audio levels to eliminate artifacts at the beginning and end of each instance of playback, though.
          • 2. Re: Use an expression to trigger a sound file?
            Mylenium Most Valuable Participant
            Pre-render the piece, add the sound in Audition, Premiere or Soundbooth, then render the final. I advise against using time-remapping with audio. There will always be skewed audio frames, regardless how careful you set it up. AE is simply not cut out to be an audio tool.

            Mylenium