Copy link to clipboard
Copied
I just finished watching Ukramedia's How To Trigger Layer Visibility with Sound and Expressions in After Effects but I haven't been able to achieve that effect after watching the tutorial over and over. Does anyone know of an AE plugin that makes it easier to accomplish?
The issue I keep running into is one of bad syntax apparently. When I enter this line of code: if (beatCounter == index -1) 100 else 0
I get this warning: Error SyntaxError: Unexpected token 'else'
I left a comment for Ukramedia's Sergei hoping he might have a solution. Would really love to get this effect to work.
Thank you in advance for any help with this.
Copy link to clipboard
Copied
That is a very well-explained tutorial. The only potential problem that I see is that there may be some punctuation missing in the if/else statement. A more standard way of controlling a variable looks like for opacity looks like this:
beatCounter = thisComp.layer("Controls").effect("Beat Counter")("Slider");
if (beatCounter == index - 1){
t = 100;
else {
t = 0;
}
t
The way the author wrote the expression failed to add a semicolon to the end of the if and else arguments. That could cause the expression to fail. Adding the opening and closing brackets also helps clear things up.
If that does not help we need to see your timeline with the modified properties of at least one problem layer showing. Select the layer, press 'uu' (the "u" key twice), then take a screenshot and drag it to the reply field or embed it using the Tool Bar and make it big. We also need to see the Audio Amplitude Graph editor with the proper channel, probably "Both Channels" selected so we can check the values.
Trapcode Sound Keys, which is part of the Trapcode Suite, is an improved Convert Audio to Keyframes tool that takes a little of the work out of controlling layer properties, but you still have to have a basic understanding of expressions.
Try downloading the project file in the YouTube description. If it also throws the error the if/else statement punctuation is the problem.
Copy link to clipboard
Copied
As Rick said, the expression from the tutorial only works with the old expressions engine.
You can also replace
if (beatCounter == index -1) 100 else 0
by
(beatCounter == index -1) ? 100 : 0
Copy link to clipboard
Copied
Also, if you need a way more accurate and robust solution for beat detection and animating layers in sync with the beat, my (paid) extension BeatEdit for Ae will be very useful.
The easiest way to let texts apeear in sync with the beat is using its "Stagger Layers" feature:
but you can also do more fancy things with its BeatWiggle, for example: