Hi there. I have a somewhat advanced question about speed and frequency control expressions, and I'm hoping some expression gurus out there may be able to help.
I'm trying to create an expression to animate an oscillating diameter of a circle that smoothly responds to changes in frequency value over time. Using slider controls, I've assigned the values of the initial circle diameter, its oscillation amplitude, and oscillation frequency. I can keyframe changing frequency values over time, but when I do this, an uneven animation results. Please refer to my attached screenshot for reference:
![AESS_1.jpg]()
The green graph represents the circle diameter size (to be completely specific, this is the 'Starting Thickness' value of the 'Beam' effect made to look like a circular glowing eye). The pink graph represents the slider value of the frequency value control. It starts at .5 and increases to 1.4 over about a second, but as you can see from the graph output when this occurs the frequency of the diameter size oscillation abruptly jumps to a rate faster than the intended target rate before arriving at the target frequency - not gradual at all. I realize I could convert my expression to keyframes and smooth things out this way, but I'd prefer to find a solution w/ the expression itself. Can someone please advise me how to create an expression that will result in a smooth, gradual change in frequency?
Below is my current expression. I use sliders to define the maximum sphere diameter size and it oscillates to a smaller diameter size and back again depending on the value of "amp" and "freq". I also have it designed to only begin the animation after a specific keyframe is reached in the composition to ensure a smooth animation (w/ out this :
initEyeSize = effect("Sldr-EyeDiameter")("Slider");
freq = effect("Sldr-EyeSizeFreq")("Slider");
amp = effect("Sldr-EyeSizeAmp")("Slider");
FXstartFrame = effect("Sldr-FXStartFrame")("Slider");
currentTime = timeToFrames();
t = currentTime - FXstartFrame;
if (t >= 0)
{thisProcTime = currentTime - FXstartFrame;
finalEyeSize = initEyeSize - Math.abs(amp*Math.sin(freq*framesToTime(thisProcTime)*2*Math.PI));}
else {initEyeSize;}
I am familiar with Dan Ebberts' expertise in the area of motion scripting and have consulted this article extensively, which is about achieving smooth frequency transitions over time w/ his linear keyframe integration technique. Specifically, I think this expression holds the key to my solution, but I'm having a hard time wrapping my head around how to integrate it w/ my current expression:
freq = effect("Slider Control")("Slider");
amp = 100;
n = freq.numKeys;
if (n > 0 && freq.key(1).time < time){
accum = freq.key(1).value*(freq.key(1).time - inPoint);
for (i = 2; i <= n; i++){
if (freq.key(i).time > time) break;
k1 = freq.key(i-1);
k2 = freq.key(i);
accum += (k1.value + k2.value)*(k2.time - k1.time)/2;
}
accum += (freq.value + freq.key(i-1).value)*(time - freq.key(i-1).time)/2;
}else{
accum = freq.value*(time - inPoint);
}
value + amp*Math.sin(accum*Math.PI*2)
My current expression allows me to generate sine wave oscillations starting from a specific keyframe of my choosing vs. the start of the composition as I understand is standard expression behavior -resulting in a smoother animation of my oscillating sphere diameter. I'd like to preserve the functionality of my current expression while integrating Dan's expression, but my previous attempts have been unsuccessful b/c Dan's expression seems to work off of the inPoint time of a layer, whereas mine is working off of time in frames as measured from a specific keyframe starting point ('FXstartFrame') not at the start of a layer. Plus I'm having a difficult time comprehending the inner workings of Dan's expression.
Are there any expression wizards out there who know how I can integrate Dan's expression into mine so that the value oscillation begins after a specific keyframe is reached AND the oscillation frequency gradually changes when the frequency value changes over time?
To help clarify all this, I'm attaching a video clip of what I'm working that reflects the animation going on indicated in my screen shot above. It features the animated circle (a glowing eye) static before the target keyframe is reached, then oscillating at the initial frequency, then oscillating wildly during the transition from frequency one to two, then oscillating at the final target frequency.
Please let me know if you need further clarifications, I realize this is somewhat of a complicated series of questions. Thanks in advance for any help you can provide!