Skip to main content
Participant
August 19, 2021
Question

How to reduce speed of text animation in the following expression ?

  • August 19, 2021
  • 1 reply
  • 1239 views

delay = .03; myDelay = delay*textIndex; t = (time - inPoint) - myDelay; if (t >= 0){ freq =2; amplitude = 100; decay = 10.0; s = amplitude*Math.cos(freq*t*2*Math.PI)/Math.exp(decay*t); [s,s] }else{ value }

This topic has been closed for replies.

1 reply

Community Expert
August 19, 2021

 

I cleaned up your expression so I could read it.

 

delay = .03; 
myDelay = delay*textIndex; 
t = (time - inPoint) - myDelay; 
if (t >= 0){ 
    freq =2; 
    amplitude = 100; 
    decay = 10.0;
    s = amplitude*Math.cos(freq*t*2*Math.PI)/Math.exp(decay*t);
    [s,s] 
}
else{ 
    value; 
}

 

You have frequency values, amplitude values, and decay values that you can change to modify the timing of those attributes. 

 

There is also a delay value in the first line that can be modified.

 

You also have a problem. "textIndex" is not a global function and is not defined. Where are you using this expression and what are you trying to do?

 

 

Participant
August 19, 2021

Hello Sir, actually I'm working on a lyrical video, and the text is not matching the lyrics of the poem, so I wanted to delay the speed of the text animation so that it just gets synced with the poem.

Dan Ebberts
Community Expert
Community Expert
August 19, 2021

I'm assuming you have this expression applied to the Amount parameter of a text animator expression selector with Based On set to Words, is that correct? If so, you can adjust the timing with the delay variable, but it seems unlikely that would ever sync with your poem exactly. I think you'd be better off to put a layer marker where you want each word to animate and modify the expression like this:

m = thisLayer.marker;
val = 0;
if (m.numKeys > 0){
  n = m.nearestKey(time).index;
  if (time < m.key(n).time)n--;
  if (textIndex <= n){
    t = time - m.key(textIndex).time;
    freq =2; 
    amplitude = 100; 
    decay = 10.0;
    s = amplitude*Math.cos(freq*t*2*Math.PI)/Math.exp(decay*t);
    val = [s,s] 
  }
}
val