1 Reply Latest reply on Oct 19, 2016 8:37 AM by Mylenium

    Triggering An Expression With Audio *HELP*

    nikolaiw36017532

      Look at the *VIDEO* that I have linked.

       

      In After Effects, I made a square and animated it simply and then I Pre-Composed the shape layer.

      Next I converted the song to keyframes with Trapcode Sound Keys and enabled Time-Remapping on the Pre-comp.

      Then I used the pick-whip tool from the Pre-Comp Time-Remapping and connected it to the audio keyframes.

       

      Then I wrote this expression in the Time-remap:

       

      threshold = 10.0;

      audioLev = thisComp.layer("SOUND KEYS").effect("Sound Keys")("Output 1");

      above = false;

      frame = Math.round(time / thisComp.frameDuration);

      while (true){

        t = frame * thisComp.frameDuration;

        if (above){

          if (audioLev.valueAtTime(t) < threshold){

            frame++;

            break;

          }

        }else if (audioLev.valueAtTime(t) >= threshold){

          above = true;

        }

        if (frame == 0){

          break;

        }

        frame--

      }

      if (! above){

        t = 0;

      }else{

        t = time - frame * thisComp.frameDuration;

      }

       

       

      Now the animation the animation is exactly as the video you saw.

      So the problem is that when the audio gets to intense, the animation doesn't get to finish before the next one starts. I want the animation to finish and if the audio is to intense, instead start the next animation even if the other one still is going.

       

      So I have been trying to find an answer for this for a long time now and I have not found anything. Please Help!!

       

      Nikolai Wärnberg 17 y/o Sweden

        • 1. Re: Triggering An Expression With Audio *HELP*
          Mylenium Most Valuable Participant

          That would completely require to refactor the code and naturally you may need multiple layers. that being the case, you get quicker results by a) eitehr using markers and manual timing or b) create multiple processed versions of your audio file that only contains the events you want to trigger your animation, but even then you will need multiple layers. There is no simple answer here it's going to entail extra work one way or the other and using multiple layers and suitable pre-processing is a lot more straightforward than meddling with code.

           

          Mylenium