2 Replies Latest reply on Aug 22, 2016 9:10 PM by Elryst

Hello, everyone! I have been having a bit of trouble within these past couple days, and I've searched almost every corner of the web trying to figure out how I need to write this expression. So I've had two expressions. One was way too complicated and the new one doesn't do exactly what I want. So first of all here was my first expression

X = 100

Y = thisComp.layer("Soundkeys 1").effect("Sound Keys")("Output 1")*1.33333;

cb = effect("Checkbox Control")("Checkbox");

if (cb.numKeys > 0){

t = cb.key(1).time;

Y =  linear(time,t,t+1,Y,.5);

Note: this is just one bar out of 63
This was given to me by another member on this forum 6 or 7 months ago. What this did is whenever the time I had one checkbox keyframe I could have the bar move slowly down over the course of a second at the end of the song. The problem with this expression is that it doesn't allow me to make the bars slowly rise upwards over a second (the reverse of what this one does).

So my solution so far has been to use an expression that allows me to have way less soundkeys layers for the solids (haven't really gotten to testing it so if you could tell me if it works or not that would be great) here is the second (new) expression, but this expression does not include scaling up or scaling down.

X = 100

temp = thisComp.layer("1-3").effect("Sound Keys")("Output 1")*1.33333;

temp2 = thisComp.layer("1-3").effect("Sound Keys")("Output 2")*1.33333;

temp3 = (temp1+temp2)/2

Y = [100, temp3]

}

[X, Y]

Again: This is just one bar out of 63

What this one does is averages the soundkeys effects instead of having so many different ranges (not important). What I am wanting to add is add to this expression  with a slider effect, or 2 checkbox keyframes, just whatever it takes to have this happen to many layers at once (while keeping my current expression) [so likely using an adjustment layer]:

But of course the scaling up at the beginning of the song and then scaling down at the ending of the song, each lasting 1 second. Sorry for such a long post, but I really would like to be able to get this done ASAP for my music promotional channel . Thank you!

PS: The only reason I am posting this is because I couldn't find it anywhere and the only thing I could find were too advanced for me to understand, but what I did understand is that they used a slider effect to control all of the layers' Y value with keyframes. Hope that additional info might be helpful

I would recommend trying the specific forum for expressions which is this: After Effects Expressions  and also try here: CreativeCOW  - you never know, maybe the amazing Dan Ebberts will respond and give you the code it's most elegant way possible

Hello again everyone. So my friend and I were finally able to come up with the two expressions that I needed in order to get it to work! Basically what I needed to do was create a null object with a slider effect and add 4 keyframes (2 at the beginning and 2 at the end where I wanted them). We then hooked up each bar to the appropriate sound keys layer and also the slider layer. These are the two expressions we were able to come up with

For a single bar that WASN'T going to be averaged, we used this expression:

`temp = thisComp.layer("1-3").effect("Sound Keys")("Output 1")*(4/3);temp = temp*thisComp.layer("Spectrum Scale").effect("Slider Control")("Slider");temp = linear(temp, 0, 100*(4/3), .5, 100*(4/3));[100, temp]`

This adds a variety of things to temp.

1. In the first line, we have "temp" hooked up the basic pick whipped expression multiplied by 4/3.

2. In the second line, we have temp pick whipped to the null layer which we named "Slider Scale" and the effect being "Slider Control" with the variable (keyframes) on "Slider".

3. The third line is a little more complicated because we needed to have it so that it had a minimum of .5 without adding +.5 to the end of the last line. This created a problem because it would cause any output, even when we didn't want it added, to be .5 higher than it should be. So we decided to add a minimum to the expression making the minimum output .5 and the maximum output the same as the first line "(4/3)".

For the averaged bars it needed a little more coding and a lot more advanced work (in my opinion). Here is the expression:

`temp1 = thisComp.layer("1-3").effect("Sound Keys")("Output 1")*(4/3);temp2 = thisComp.layer("1-3").effect("Sound Keys")("Output 2")*(4/3);temp = (temp1+temp2)/2;temp = temp*thisComp.layer("Spectrum Scale").effect("Slider Control")("Slider");temp = linear(temp, 0, 100*(4/3), .5, 100*(4/3));`

So this is a lot heftier of an expression at a first glance, but really it's mostly the same thing.

1. Starting off in the first line, we have it so that temp1 is the first output used in sound keys multiplied by 4/3.

2. In the second line, we have the exact same thing as the first line only we used the second output in the sound keys layer.

3. The third line is where we started to have to change everything. before it was referred to as "temp3" but we couldn't use that with what we wanted to do. So what we ended up doing was from then on out changing all the "temp3" references to just "temp". We then did the same thing as we did in the first expression pick whipping it to the slider control output.

4. In the fourth line, this is where we had to set up another minimum and maximum in order for the bars to not disappear when the audio reached a point of 0 or the keyframes we set in the slider were set as 0. So we made the minimum output .5 and the maximum output 100*(4/3) using the "linear" expression.

Due to my friend's vast knowledge in these types of templates and javascript, this only took about 30 minutes to solve the problem. It does exactly what I wanted it to do in my original post, and I am very grateful to have a friend who can help me out like this. I'd like to thank all of you in the community forum for helping people constantly with expressions even if they are extremely simple. You help a lot of people who simply cannot find the answer they are looking for. I'll show what I did with the slider effect keyframes now

The last 2 keyframes are the same exact values but reversed. The end result is completely what I wanted (shown in the OP) so if someone wants to know how to scale multiple layers up in the beginning and then down at the end please send them this. Thanks again to the community, much respect!