Sync wiggle to audio

Moderators: Disciple, zlovatt

Post Reply
m|3
Posts: 1
Joined: May 9th, 2005, 11:05 am

Hi All!

I'd like to sync the wiggle (actually it's more of a vibrate) of a layer to the music being played. So when there is little to no music going on the layer should not vibrate. The layer itself has no position keyframes as well.

I came across Paul Tuersley's Expression Wiggler -- which has gotten me halfway to my goal...thanks Paul!

Can anyone direct me as to how/if this can be done? I have ZERO expression/scripting expertise.
// m|3
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

Maybe you've already tried this; if you check 'Slider controls for Mag' in the advanced controls of the Expression Wiggler palette, when you use the script to add wiggle, you get a 'wiggle control' which you can use to vary the amount of wiggle. Use Keyframe Assistant / Convert Audio To Keyframes on your audio layer and paste the resulting keyframes into the Wiggle Control property, the wiggle amount will vary in time with the music.

The keyframed values will probably be pretty low and unsuitable to use to control the wiggle magnitude. So for this I'd twirl open the 'Wiggle Magnitude - Slider' property to view its value graph in the Timeline and scrub the min/max values to the left of the graph until the keyframed values fill the height of the graph with nice peaks and troughs. Remember these min/max values.

To change the value range so it matches the min/max you want for the amount of wiggle, add an expression like this to the 'Wiggle Magnitude - Slider' property:
linear(value, 3, 5, 0, 100);

Replace the first two values with the min and max you chose in the value graph, the last two values are the min and max you want for the wiggle effect. This expression converts the values into the new range.

The really useful thing about using the value graph method to choose those min/max values, is that you get a clear visual representation of exactly how the audio data will effect the result. Personally I use this technique to sync things to music without even using wiggle expressions, just by linking properties directly (i.e. using the pickwhip).


One last thing, if as you said, you want a roof to jump up and down, maybe you've applied a wiggle to the layer's Y Position and you don't want it to drop beneath a certain value. For this, you could locate the expression with the wiggle (i.e the one on your 'wiggled' property) and replace the current expression that looks something like this:
mag = thisComp.layer("Wiggle Controls 1").effect("Wiggle Magnitude")(1);
wig = wiggle(1,mag);
[value[0], wig[1]];

with an expression like this:
mag = thisComp.layer("Wiggle Controls 1").effect("Wiggle Magnitude")(1);
wig = wiggle(1,mag);
[value[0], clamp(wig[1], -1000, 288)];

In that example the resulting Y Position value would be 'clamp'ed between the values of -1000 and 288.

Paul T
Post Reply