ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Trigger scale animation up/down on every second beat

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Dagur Maunason
Trigger scale animation up/down on every second beat
on Dec 8, 2016 at 12:31:48 pm
Last Edited By Dagur Maunason on Dec 8, 2016 at 12:32:15 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]
}


Return to posts index

David Kaminski
Re: Trigger scale animation up/down on every second beat
on Dec 11, 2016 at 5:55:50 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) &lt; 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;


Return to posts index

David Kaminski
Re: Trigger scale animation up/down on every second beat
on Dec 11, 2016 at 5:59:08 pm

Change the "<" to a less than sign. I don't know why this site changed it.


Return to posts index


David Kaminski
Re: Trigger scale animation up/down on every second beat
on Dec 11, 2016 at 6:04:30 pm

Well this is frustrating. The line should read-

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


Return to posts index

Dagur Maunason
Re: Trigger scale animation up/down on every second beat
on Dec 14, 2016 at 12:49:48 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?


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]