Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Trigger scale animation up/down on every second beat

  • Trigger scale animation up/down on every second beat

    Posted by Dagur Maunason on December 8, 2016 at 12:31 pm

    Hey!

    I’m trying to figure out how to scale a paths width up and down on every second beat, meaning when one beat hits it scales up and when the next beat hits it scales down, using a transition and not snapping to the value, something like tweening in AS/Flash back in the days :). I’m using Soundkeys btw, and I think the logic would be something like below but I’m not sure how to actually make it work. I’m getting errors but I’ve tried everything I can think of and would be very greatful for any help!

    pathWidth = content("Rectangle 1").content("Rectangle Path 1").size[0];
    soundkeysValue = thisComp.layer("Snare").effect("Sound Keys")("Output 2");

    if (soundkeysValue == 100 && pathWidth == 10){
    size[100,2200]
    }else if (soundkeysValue == 100 && pathWidth == 100){
    size[10,2200]
    }

    Dagur Maunason replied 9 years, 4 months ago 2 Members · 4 Replies
  • 4 Replies
  • David Kaminski

    December 11, 2016 at 5:55 pm

    I would be curious to know the proper way to do this also. I have a workaround that is not the real deal, but may pass for what you’re looking for.

    I put this expression together based on some examples on this forum. I can’t remember exactly where, but I’m sure Mr. Ebberts is to thank. This will only give a teleporting effect to start… But if you were to then convert the expression into keyframes and turn on motion blur, it gives the effect of movement back and forth on each beat.

    // Increase value by 1 on each beat
    output = thisComp.layer("Snare").effect("Sound Keys")("Output 2");

    above = false;
    frame = Math.round(time / thisComp.frameDuration);
    val = 0;
    while (frame >= 0){
    t = frame * thisComp.frameDuration;
    if (above){
    if (output.valueAtTime(t) < 30){
    above = false;}
    }
    else if (output.valueAtTime(t) >= 30){
    above = true;
    val++;}
    frame--}
    val

    //On each increase, alternate back and forth
    zVal1 = [100,2200];
    zVal2 = [10,2200];
    val%2 ? zVal2 : zVal1;

  • David Kaminski

    December 11, 2016 at 5:59 pm

    Change the “<” to a less than sign. I don’t know why this site changed it.

  • David Kaminski

    December 11, 2016 at 6:04 pm

    Well this is frustrating. The line should read-

    if (output.valueAtTime(t) < 30){

  • Dagur Maunason

    December 14, 2016 at 12:49 am

    Thanks for your help David! Unfortunately that doesn’t work for animating a paths width it seems, it gives me a sharp jump and the motion blur has no effect.

    Anyone?

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy