Copy link to clipboard
Copied
Hello cows,
am new to this forum so i try to be specific as possible to save everbodys time:
I have a click sound, that translates into very clear keyframes with values between 10 and 20 at a click and I want to my graphic to be 10px further up everytime a click/keyframe value occurs
BUT
I need the animation to be linear but smooth starting and ending just halfway between the clicks so the next animation can start just in time. The clicks are not unison but vary in clicks per minute.
I already tried
ease(value, 11, 20, 0, 10)
smooth(width=0.1, samples=50)
smooth goes into the right direction but I cant change it to be precise where i need the animation to start and end and to be at 10 exact at the click.
Could somebody please point me into the right direction or am i missing something?
THANKS!
Copy link to clipboard
Copied
It would help if you could post a screen shot of what your clicks look like in the graph editor.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
It's pretty complex. It will probably look something like this:
// count previous beats
threshold = 10.0;
moveAmt = [0,-10];
audioLev = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
above = false;
frame = timeToFrames(time);
n = 0;
fSave = 0;
while (frame >= 0){
t = framesToTime(frame);
if (above){
if (audioLev.valueAtTime(t) < threshold){
above = false;
}
}else if (audioLev.valueAtTime(t) >= threshold){
if (fSave == 0) fSave = frame;
above = true;
n++;
}
frame--
}
// find the next beat
frame = Math.round(time / thisComp.frameDuration) + 1;
above = audioLev.value > threshold
while(framesToTime(frame) < thisComp.duration){
t = framesToTime(frame);
if (above){
if (audioLev.valueAtTime(t) < threshold){
above = false;
}
}else if (audioLev.valueAtTime(t) >= threshold){
break;
}
frame++;
}
dt = time - framesToTime(fSave);
tTot = framesToTime(frame - fSave);
value + n*moveAmt + linear(dt,0,tTot,[0,0],moveAmt)
Copy link to clipboard
Copied
Dear Dan,
thank you again for the taking the time to respond on this. Oh I didnt think it was so complex. When applying your code the error i get expects an expression result that has to be of dimension 1, not 2 like in the screenshot attached.
Isnt there a way to smooth the value of the current keyframe across a certain amount of frames before and after which could be calculated for every 5 seconds or something?
Thanks again!
Copy link to clipboard
Copied
I'm confused. It looks like you've applied the expression to your audio layer slider. It should be applied to some other layer's position property and that layer will move in response to the audio.
Copy link to clipboard
Copied
Thanks again for the input. I appreciate this.
Yes i tried it on the audio layer slider and indeed there is no error if applied directly to a graphics position property.
Now I see, that i didnt specify exactly what is was trying to achieve and I am very sorry for this.
Because the graphic is moving upwards steadily but i wanted to create a bouncing effect with the graphic going up and down only raising 10px up before going 10px down again.
I'm so sorry that i didnt communicate this well and I dont expect you dont put up with this any further because of my mistake.
I can mark your reply as correct nonetheless if you want?
Copy link to clipboard
Copied
What's causing the graphic to move currently? And how do you want the audio to modify that?
Copy link to clipboard
Copied
The graphic is moving because of the amplitudes keyframes each time 10px further up as specified.
my initial plan was to have the graphic also moving down the same amount within the same click/beat to make it look like the graphic is bouncing accordingly to every click you can hear.
imagine a head nodding to a beat, where the head moves up a specified amount and down again before the next click/beat triggers the same.
thanks!
Copy link to clipboard
Copied
So what does the expression connecting the graphic's position to the audio look like now?