Writing an expression to trigger a sound
Hi folks—I want to create an expression where a sound is triggered when X happens. Let's say, every time a null gets to a certain point, play from 0-4 seconds on an audio clip.
I'm close, but having trouble with the last part. Here's what I have on the Time Remap keyframes for my audio track:
countstart = 0;
countend = 0;
if (thisComp.layer("Null 9").transform.xPosition > 1080){
countstart = time;
countend = time+4;
}
linear(time,countstart, countend, 0,4);
The problem is that time is re-defined on every frame. So instead of playing from the current time and just running, the "play from" time is always equal to the current time, and it never catches up.
I think a solution would be: when the Null reaches X, have the Expression jot down the current time, but only once. Also, do this every time the null crosses X. But I'm stumped on how to do that. Help would be greatly appreciated.
