• Global community
• Language:
• Deutsch
• English
• Español
• Français
• Português
• 日本語コミュニティ
Dedicated community for Japanese speakers
• 한국 커뮤니티
Dedicated community for Korean speakers
• Re: How can I associate an expression to move a ro...

# How can I associate an expression to move a rotating wheel X times depending on audio amplitude?

New Here ,
Aug 14, 2019 Aug 14, 2019

Copied

My problem is simple but I can't for the love of anything figure it out. I'm trying to move a rotation wheel X values depending on the amplitude of a track.

Basically = I want the CC Kaleida Rotation to move according to the audio amplitude keyframe value I choose, say <>55.

I used linear(value,50,55,0,100) to move the size slider, which makes sense because the slider goes from 0 to 100, but the rotation wheel goes from 0 to 360 and is multiplied by X the times of rotation.

I checked this link and got an idea where to begin but I still can't figure it out.

I need to render the project by tomorrow and I've been crunching my brain into this but I don't see it. I would really appreciate it if anyone helps me out or at least point me out where to learn.

TOPICS
Expressions

Views

970

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
5 Replies 5
Community Expert ,
Aug 18, 2019 Aug 18, 2019

Copied

Not really sure what you want to achieve, but if you want 2 full rotations (2*360 degrees), for example, you could do

linear(value,50,55,0,2*360)

Also note that my (paid) extension BeatEdit makes animating any properties to the beat much easier:

Here is an example

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Engaged ,
Sep 13, 2019 Sep 13, 2019

Copied

You can set the rotation to a number larger than one rotation just by setting it to the total number of degrees. So if you wanted three and a half rotations you'd set the rotation to <does mental arithmetic> 1260. In the UI it would say 3 + 180. So just multiply it by whatever you need.

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Sep 13, 2019 Sep 13, 2019

Copied

Let's get a couple of things straight.

1. When you use Convert Audio to Keyframes you get a new layer named Audio Amplitude that has Left, Right and Both Channels sliders. The range of these values is easily viewed using the Graph Editor with Edit Value Graph selected. Normal audio ranges are a lot less than 0 to 100 so you have to pick the maximum value you want to use.
2. If you use just an interpolation method like linear(t, tMin, tMax, value1, value2) to drive rotation, no matter what you do this method will rotate a property back and forth. You cannot do cumulative rotations using this simple method
3. If you are using the simple linear interpolation method then t would be the value of Both Sliders (or one of the other sliders) tMin would be the minimum value you get from the graph editor to start rotation, tMax would be the maximum you get from the graph editor for the maximum rotation of the layer, value1 would be the starting rotation value (something like zero) and value2 would be the maximum rotation value in degrees - like 180 or 720. It just depends on how much you want the rotation property to change when the audio amplitude increases.

That should give you an understanding of how the Interpolation Methods work in expressions.

If you want to have the rotation property increase every time the value of Both Channels goes up but not return to the original position when the audio levels drop you need a lot more complicated expression and it is going to be recursive, which means it will take longer to calculate the longer the layer is. If that is what you want, let us know Otherwise something like this should work:

``````t = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
r = linear(t, 5, 25, 0, 55)``````

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Beginner ,
Jul 16, 2021 Jul 16, 2021

Copied

Hi I would like to know how to have the rotation property increase every time the value of Both Channels goes up but not return to the original position when the audio levels drop. What is the expression for this?

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Community Expert ,
Aug 04, 2021 Aug 04, 2021

Copied

LATEST

Take a look at Dan Ebberts beat counter

As it is written, every time the Both Channels slider value goes over 10 the value goes up by 1.  You could multiply the result by 10 to get the angle to increase 10º every time the value goes over 10.

I don't have time to write an accumulator right now because I'm not very good at that part of javascript but this expression would only return positive values so that as the value of Both Channels goes up the value would change from 0 to a maximum of 90º but if the value goes down the value would be zero.

``````ref = thisComp.layer("Audio Amplitude");
t = ref.effect("Both Channels")("Slider");
tMin = 0;
tMax = 30;
value1 = 0;
value2 = 90;
r = linear(t, tMin, tMax, value1, value2);

if (t < t.valueAtTime(time - thisComp.frameDuration)){
a = 0;
}
else{
a = r;
}
``````

Combine that expression with an accumulator (value ++) like Dan's beat counter and you would have an expression that rotated a layer clockwise based on the audio level but never moved counterclockwise.

If Dan sees this post he will be able to combine the two ideas into some working code for you in a couple of minutes. I don't have the time to do it now because a quick search for "javascript accumulator" didn't give me a working solution.

Likes

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Resources
Troubleshooting FAQs
After Effects Community Recap
Getting started with After Effects