• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Rotation Expression

Community Beginner ,
Aug 07, 2021 Aug 07, 2021

Copy link to clipboard

Copied

I saw a comment on the thread I have linked below, I will also attach a couple screenshots of the comment which describes the expression I need. I want to know how to make the rotation property increase every time the value of both channels goes up instead of returning to the original position when the audio levels drop.

 

Screenshot 2021-08-07 at 18.29.36.pngScreenshot 2021-08-07 at 18.29.47.png

 

https://community.adobe.com/t5/after-effects/how-can-i-associate-an-expression-to-move-a-rotating-wh...

TOPICS
Audio , Expressions , How to

Views

405

Translate

Translate

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 guidelines

correct answers 1 Correct answer

Community Expert , Aug 21, 2021 Aug 21, 2021

You could try playing around with this, but it'll get pretty slow if your comp is long:

a = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
constSpeed = 10;
mult = 10;
n = a.numKeys;
if (n > 0 && a.key(1).time < time){
  accum = a.key(1).value*(a.key(1).time - inPoint);
  for (i = 2; i <= n; i++){
    if (a.key(i).time > time) break;
    k1 = a.key(i-1);
    k2 = a.key(i);
    accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
  }
  accum += (a.value + a.key(i-1).value)*(t
...

Votes

Translate

Translate
Community Expert ,
Aug 07, 2021 Aug 07, 2021

Copy link to clipboard

Copied

Your question could be interpreted more than one way, and it's not clear which one you're after, but I think this is one possible solution:

a = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
mult = 1.0;
f = timeToFrames(time);
accum = 0;
prev = 0;
for (i = 0; i <= f; i++){
  next = a.valueAtTime(framesToTime(i));
  if (next > prev){
    accum += (next - prev)*mult;
  }
  prev = next;
}
accum

 

Votes

Translate

Translate

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 guidelines
Community Beginner ,
Aug 15, 2021 Aug 15, 2021

Copy link to clipboard

Copied

Hi Dan thanks for your response. The effect I am aiming to achieve is to have the rotation of the subject increase smoothly as the volume of the audio amplitude/audio keyframes increases and as the volume decreases I'd like the rotation to slow down while still rotating in the same direction (clockwise). I tried to use the expression you gave me however thte motion is really jagged and not smooth. Hope that made sense, if possible it would be great if we could have a zoom call so I can share my screen with you but if not please provide the appropriate expression.

 

Many Thanks!

Votes

Translate

Translate

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 guidelines
Community Expert ,
Aug 15, 2021 Aug 15, 2021

Copy link to clipboard

Copied

The key is coming up with the algorithm that defines the relationship between the audio that has occured in the past and the current rotation value. Maybe you could provide a sketch of what that would look like?

Votes

Translate

Translate

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 guidelines
Community Beginner ,
Aug 21, 2021 Aug 21, 2021

Copy link to clipboard

Copied

Hi Dan,

 

I have made a video detailing what I want hope this helps. rotation expression explaination 

Votes

Translate

Translate

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 guidelines
Community Expert ,
Aug 21, 2021 Aug 21, 2021

Copy link to clipboard

Copied

You could try playing around with this, but it'll get pretty slow if your comp is long:

a = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
constSpeed = 10;
mult = 10;
n = a.numKeys;
if (n > 0 && a.key(1).time < time){
  accum = a.key(1).value*(a.key(1).time - inPoint);
  for (i = 2; i <= n; i++){
    if (a.key(i).time > time) break;
    k1 = a.key(i-1);
    k2 = a.key(i);
    accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
  }
  accum += (a.value + a.key(i-1).value)*(time - a.key(i-1).time)/2;
}else{
  accum = a.value*(time - inPoint);
}
value + accum*mult + constSpeed*(time-inPoint)

Adjust constSpeed to control how fast it rotates with low/no audio and adjust mult to control how much it responds to loud audio.

 

 

Votes

Translate

Translate

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 guidelines
Community Beginner ,
Aug 21, 2021 Aug 21, 2021

Copy link to clipboard

Copied

Thank you this did the trick! Are there any other values within this expression I can manipulate and play with?

Votes

Translate

Translate

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 guidelines
Community Expert ,
Aug 21, 2021 Aug 21, 2021

Copy link to clipboard

Copied

No, not really.

Votes

Translate

Translate

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 guidelines
Community Beginner ,
Aug 21, 2021 Aug 21, 2021

Copy link to clipboard

Copied

LATEST

I'm just asking because as I adjust the const speed lower and the mult, the difference between slow and fast rotation isn't drastic enough. const speed has little effect on the because the mult also increases the minimum rotation so much.

Votes

Translate

Translate

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 guidelines