-
Scale Triggered by Audio Threshold
I am looking for an expression that triggers a sudden change in scale when a threshold in audio amplitude is reached, and which then eases back until the next threshold breach.
So far I’ve successfully linked scaled and amplitude with a simple expression, but that approach is hyper responsive (i.e. the scale property twitches at nearly every keyframe).
In contrast, I’ve been able to use expressions posted on Dan Ebbert’s site (and pasted below) and get them to respond only to amplitudes above the threshold. But while it works for the wobble effect, and color change; I’m missing the step(s) needed to adjust the code for scale.
At the moment, when I combine the codes below, the scale expression does its thing at the beginning of the comp and remains unresponsive to the music.
i’m sure it’s probably a simple issue. i’d very much appreciate any help.~Raf
here is the code used to trigger
threshold = 12.0;
audioLev = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
above = false;
frame = Math.round(time / thisComp.frameDuration);
while (true){
t = frame * thisComp.frameDuration;
if (above){
if (audioLev.valueAtTime(t) < threshold){ frame++; break; } }else if (audioLev.valueAtTime(t) >= threshold){
above = true;
}
if (frame == 0){
break;
}
frame–
}
if (! above){
t = 0;
}else{
t = time – frame * thisComp.frameDuration;
}and here is the code i want activated by the “trigger”
freq =1;
amplitude = 505;
decay = 5.0;s = amplitude*Math.sin(freq*time*2*Math.PI)/Math.exp(decay*time);
scale + [s,s]