-
Trigger effect every third event
Hi all,
I’m working with Trapcode soundkeys, and I have three (or more) layers, that I want to react to a soundkeys output in alternating fashion.
More specifically, I want to get the glow intensity of the three layers to react to the output (a kick drum rhythm), but to varying degrees. So if layer one’s glow reaches 100%, I want layer two to simultaneously reach a max of 75%, and layer three a max of 50%. And For every kick hit, I want those three values to continuously cycle between those three elements so that all three at no point share the same value.
I was thinking I could try to make some kind of three-phase circuit expression for each element, but so far I haven’t had any luck figuring out a way to do that. AE accepts the code I came up with, but the element doesn’t react the way I’m expecting. I’m thinking there’s a far simpler and more elegant way to do this, but if not, how could I fix what I have below?
hit = thisComp.layer("Sound Keys").effect("Sound Keys")("Output 1");
a = 1if (a = 1) {
hit;
// links element glow intensity to Soundkeys output. In this example
//I only want the glow to activate on the 1st kick drum occurrence,
//and for nothing to happen every 2nd and 3rd occurence.
};if (a = 1 && hit > 50) {
b = 1;//if "a = 1" condition is active AND the soundkeys output value
//is greater than 50, activate "b=1" switch. I'm using a value
//greater than 50 to signify a kick hit.};
if (a = 1 && b = 1 && hit < 20) {
a = 2;
//if "a=1" condition is active AND "b=1" switch is active
//AND the Soundkeys output is below 20, I wanted this
//to disable the "a=1" condition and activate the "a=2" conditon,
//thus disabling the glow intensity stored in "a=1",
//and activating the next effect stored in "a=2".
//Ideally I wanted "hit = 0" here as well, but given that the
//kick drum is playing simultaneously with other audio elements
//in the same frequency range, the output rarely reaches 0.
//This is also problematic because, once the output falls
//below 20, the effect abruptly cuts off. I would prefer
//it to be a smooth transition.
};if (a = 2) {
// repeat process with 2nd effect.};
if (a = 2 && hit > 50) {
b = 2;};
if (a = 2 && b = 2 && hit < 20) {
a = 3 ;
};if (a = 3) {
// repeat process with 3rd effect.
};if (a = 3 && hit > 50) {
b = 3;
};if (a = 3 && b = 3 && hit < 20) {
a = 1;
b = 0;
//supposed to trigger a cycle by making "a=1" happen again,
//but this does not seem to happen. What I'm noticing instead
//is that the glow only seems to occur when the output is
//below one of the values I set above. I'm unsure if the value
//is the 50 or 20. I can tell as much because I have one of
//the other three elements pickwhipped directly to the output,
//so that It always reacts to the kick. The element with the above
//expression only reacts as the glow for the other element is
//dying out. But Once the output exceeds a certain value, the glow
//for this element abruptly cuts off, while the directly linked
//element proceeds to reach full glow intensity.
};