Skip to main content
araustin
Participant
April 24, 2019
Answered

[AE] Smoothing keyframes for wiggle rotation w/ audio

  • April 24, 2019
  • 2 replies
  • 1514 views

Currently I'm trying to make a montage edit where I can easily add any footage and music and the footage will automatically "react" to the music. Problem is, I am having trouble creating a smooth wiggling effect. Each set key appears to have large amounts of variation in areas where the intensity of the music is fluctuating quickly. This results in the wiggling effect to fluctuate quickly, creating a jittery effect. I have tried many approaches. Initially tried using the smooth function, and lately have been trying to utilize integration to achieve a smooth effect, however haven't had much luck with that either. My latest result is just a result of me messing around with many values, so it may look a bit messy. Any suggestions/references to achieving the effect I have in mind would be great, thanks.

freq = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");

n = freq.numKeys; //numbers of keys in layer

if (n > 0 && freq.key(1).time < time) { //at least past the first frame and second frame.

  accum = freq.key(1).value * (freq.key(1).time - inPoint);

  for (i=2; i <= n; i+=1) {

    if (freq.key(i).time > time) break;

    k1 = freq.key(i - 1);

    k2 = freq.key(i);

    accum += (((k2.value - k1.value) * (k2.time - k1.time)) / 2);

  }

  accum += (freq.value - freq.key(i - 1).value) * (time - freq.key(i - 1).time) / 2;

} else {

  accum = freq.value * (time - inPoint);

}

linear((freq.smooth(11, 83)*0.25) * accum, 6, 20, 0, 12);

NOTE | I am using the wiggle effect (rotation) to manipulate the screen movement instead of the wiggle function.

This topic has been closed for replies.
Correct answer Mylenium

You need to integrate the time parameter, not the actual values. That's explained on Dan Ebbert's site as well.

Mylenium

2 replies

araustin
araustinAuthor
Participant
May 9, 2019

I went back and corrected my expression. It has worked for the most part, however the first 4 seconds of my footage does not wiggle smoothly at all. Instead creates a spasmic rotational animation (values quickly fluctuating) and then suddenly starts becoming incredibly smooth. Wondering how I could correct this. Also, I want to know if there is a way to optimize the expression. It can take anywhere from 0 to 8 seconds to render just one frame. This makes it incredibly difficult to test my footage, making it hard to get anything done. Thanks for the help thus far.

My current code:

freq = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");

amp = 12;

n = freq.numKeys;

v = 1;

if (n > 0 && freq.key(1 + (v - 1)).time < time){

  accum = freq.key(1).value*(freq.key(1).time - inPoint);

  for (i = 2 + (v - 1); i <= n; i+=v){

    if (freq.key(i).time > time) break;

    k1 = freq.key(i-v);

    k2 = freq.key(i);

    accum += ((k1.value + k2.value)*(k2.time - k1.time));

  }

  accum += ((freq.value + freq.key(i-v).value)*(time - freq.key(i-v).time));

}

//wiggle(freq, amp, octaves, amp_mult, time)

wiggle(0.002, amp, 3, 1, accum) + 10;

Mylenium
MyleniumCorrect answer
Legend
April 25, 2019

You need to integrate the time parameter, not the actual values. That's explained on Dan Ebbert's site as well.

Mylenium