Help with expression for jumping to new X position above an audio threshold
Hi all,
Firstly, many thanks for helping even if you're just reading this thread. I'm wondering if all you good people could help me with a personal project I'm working on. Basically I'm trying to make an image jump randomly in the X direction whenever the audio amplitude goes above a certain level, otherwise it stays at that new position.
i.e. Image starts at 900px and at each beat above 10 amplitude it jumps to a random number between 880 and 920px before staying there until the amplitude jumps again and it moves another amount plus or minus a number of pixels (say 20 as above).
My current expression is as below, and it's great for a kind of wiggle effect, but I can't seem to get it to increment the position it just always goes back to the origin.
audioLev = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
for (i = 0; i < thisComp.frameDuration; i++) {
if (audioLev < 11.0){
value;
} else if (audioLev >= 10.0){
[transform.xPosition += random(-10, 10)]
}
}
Seeing other answers that have been given, I have no doubt there's something simple I'm missing.
