Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Progressive wiggle – still having issues! FAO Dan!

  • Progressive wiggle – still having issues! FAO Dan!

    Posted by Nico Jones on July 13, 2010 at 11:07 am

    Hi there,

    I’m still having difficulty in getting a smooth move between wiggle frequency keyframes. I used to get a frantic wiggle between the keyframes when AE recalculated the location on each frame, and then Dan gave me this expression…

    freq = thisComp.layer(“Wiggle Control Sliders”).effect(“FREQUENCY”)(“Slider”);
    amp = thisComp.layer(“Wiggle Control Sliders”).effect(“AMOUNT”)(“Slider”);

    if (freq.numKeys > 0){
    accum = 0;
    v0 = freq.valueAtTime(0);
    t0 = 0;
    i = 1;
    while (i <= freq.numKeys){ t = freq.key(i).time; if (t < time){ accum += (v0 + freq.key(i).value)*(t - t0)/2; v0 = freq.key(i).value; t0 = t; if (i == freq.numKeys){ accum += (time - t0)*v0; } }else{ accum += (freq + v0)*(time - t0)/2; break; } i++; } }else{ accum = freq*time; } wiggle(1,amp,1,.5,accum); ...which seemed to work at his end but not mine - I get a big movement jerk after the last keyframe. Here is a project file with the expression applied, and the problem frame marked. I'm working in CS3 if that makes a difference. Does this work with you Dan/anybody else? I really need to solve this problem if at all possible 🙂 https://webfilemanager.co.uk/dsf.php?fileid=GVkRrPyu

    Many thanks,

    nico

    Dan Ebberts replied 11 years, 8 months ago 6 Members · 13 Replies
  • 13 Replies
  • Filip Vandueren

    July 13, 2010 at 3:46 pm

    Both the code and your project work fine for me.

  • Nico Jones

    July 14, 2010 at 9:32 am

    Ack. That’s not good. Are you on CS5? CS4? Thanks for having a look!

    Nico J BB

  • Filip Vandueren

    July 14, 2010 at 1:08 pm

    Checked in CS4 it worked, just checked in CS3 it’s broken.

    However, this does seem to work, and is even more correct IMHO


    freq = thisComp.layer("Wiggle Control Sliders").effect("FREQUENCY")("Slider");
    amp = thisComp.layer("Wiggle Control Sliders").effect("AMOUNT")("Slider");

    if (freq.numKeys > 0){
    accum = 0;
    for (t=0;t<=time;t+=thisComp.frameDuration) { accum+=freq.valueAtTime(t) } accum*=thisComp.frameDuration; }else{ accum = freq*time; } wiggle(1,amp,1,.5,accum);

    I'm not sure why Dan chose to do a kind of linear interpolation between the keyframes himself (one reason would be because there are fewer calculations), because it doesn't take in account any seasing you may but on the keyframes of Slider Control.
    The downside of my solution is it uses a lot more calculations (one per passed frame) whereas Dan's only uses one per passed keyframe, so this could get slow on very long compositions.

    Also, I'm scratching my head why the original doesn't work in CS3 and does in later versions

  • Dan Ebberts

    July 14, 2010 at 6:01 pm

    Here’s a different approach that might work for you.

    freq = thisComp.layer("Wiggle Control Sliders").effect("FREQUENCY")("Slider");
    amp = thisComp.layer("Wiggle Control Sliders").effect("AMOUNT")("Slider");

    if (freq.numKeys > 0){
    if (time &lt= freq.key(1).time || time &gt= freq.key(freq.numKeys).time)
    wiggle(freq,amp)
    else{
    n = freq.nearestKey(time).index;
    if (freq.key(n).time > time) n--;
    f1 = freq.key(n).value;
    f2 = freq.key(n+1).value;
    t1 = freq.key(n).time;
    t2 = freq.key(n+1).time;
    w1 = wiggle(f1,amp);
    w2 = wiggle(f2,amp);
    linear(time,t1,t2,w1,w2);
    }
    }else{
    wiggle(freq,amp)
    }

    I had to do some HTML manipulation to get this code to post correctly – hopefully I got everything.

    Dan

  • Nico Jones

    July 15, 2010 at 3:29 pm

    Looks like that’s done it! Thanks so much for sticking with it guys – it’s a crucial part of a music vid I’m working on and it’s really, really helped me out.

    nj

    Nico J BB

  • Nico Jones

    July 15, 2010 at 3:48 pm

    How can I amend this expression so that I can apply it straight onto the position of a 3D object and have it only affect X+Y, not Z? I’m having weird issues when I try to split them…

    freq = thisComp.layer(“Wiggle Control Sliders”).effect(“FREQUENCY”)(“Slider”);
    amp = thisComp.layer(“Wiggle Control Sliders”).effect(“AMOUNT”)(“Slider”);

    if (freq.numKeys > 0){
    if (time <= freq.key(1).time || time >= freq.key(freq.numKeys).time)
    wiggle(freq,amp)
    else{
    n = freq.nearestKey(time).index;
    if (freq.key(n).time > time) n–;
    f1 = freq.key(n).value;
    f2 = freq.key(n+1).value;
    t1 = freq.key(n).time;
    t2 = freq.key(n+1).time;
    w1 = wiggle(f1,amp);
    w2 = wiggle(f2,amp);
    linear(time,t1,t2,w1,w2);
    }
    }else{
    wiggle(freq,amp)
    }

    Nico J BB

  • Dan Ebberts

    July 15, 2010 at 4:18 pm

    Like this:

    freq = thisComp.layer("Wiggle Control Sliders").effect("FREQUENCY")("Slider");
    amp = thisComp.layer("Wiggle Control Sliders").effect("AMOUNT")("Slider");

    if (freq.numKeys > 0){
    if (time <= freq.key(1).time || time >= freq.key(freq.numKeys).time)
    wiggle(freq,amp)
    else{
    n = freq.nearestKey(time).index;
    if (freq.key(n).time > time) n--;
    f1 = freq.key(n).value;
    f2 = freq.key(n+1).value;
    t1 = freq.key(n).time;
    t2 = freq.key(n+1).time;
    w1 = wiggle(f1,amp);
    w2 = wiggle(f2,amp);
    w = linear(time,t1,t2,w1,w2);
    [w[0],w[1],value[2]]
    }
    }else{
    w = wiggle(freq,amp);
    [w[0],w[1],value[2]]
    }

    Dan

  • Nico Jones

    July 15, 2010 at 6:02 pm

    Fan-flipping-tastic. Thanks!

    Nico J BB

  • Steve Roberts

    December 4, 2011 at 3:29 pm

    Thanks, Filip and Dan. Your expressions helped me out on my current project.

  • Jesse Jost

    August 1, 2012 at 10:50 pm

    Hi Guys,

    Trying to get this to work, and the previous project files are missing from the Download Link.

    I am a little new to expressions, but have a basic knowledge. I can’t seem to figure out where to paste the expression…Directly into the Position property? As well, how would I add my sliders, just the slider control effect?

    If any one could apply this expression with sliders and upload a project file, I’m sure this would be the easiest way for me to investigate, rather than articulating back and forth on this board.

    Thank you so much you guys, this community is a wealth of knowledge.

    Cheers

    Jesse

Page 1 of 2

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