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.
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
...
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
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!
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?
Copy link to clipboard
Copied
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.
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?
Copy link to clipboard
Copied
No, not really.
Copy link to clipboard
Copied
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.