It gets tricky any time you try to control speed or frequency. If you’re using linear keyframes, you can use a modified linear keyframe integrator:
amp = 50;
freqMult = .05;
n = numKeys;
i = 0;
if (n > 0 && key(1).time < time){
accum = velocityAtTime(key(1).time)[0]*(key(1).time - inPoint);
for (i = 2; i <= n; i++){
if (key(i).time > time) break;
k1 = key(i-1);
k2 = key(i);
accum += (velocityAtTime(k1.time)[0] + velocityAtTime(k2.time - .001)[0])*(k2.time - k1.time)/2;
}
accum += (velocity[0] + velocityAtTime(key(i-1).time + .001)[0])*(time - key(i-1).time)/2;
}else{
accum = velocityAtTime(inPoint)[0]*(time - inPoint);
}
y = amp*Math.abs(Math.sin(accum*freqMult));
value - [0,y]
Dan