1 Reply Latest reply on Jun 10, 2016 10:09 PM by Rick Gerard

    Increase expression variable using a slider in a separate layer?


      Hi. I'm Yuvraj and I have a problem


      I am making a music visualiser in Ae CS6. Stock plugins and no budget. I have 4 layers that I would like to move right at different defined speeds to achieve a kind of parallax effect. There should be some basic, constant movement and also, when the bass hits (each kick drum), I would like the layers to move faster, but also then slow down once the kick drum is finished. So it will be a constant plus a variable (dependent on my bass keyframes). I have exported a bass-boosted and treble-dehanced version of my song to keyframes and now have a layer with a slider control which in expression is referred to as "thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider") ". I set a constant for the y-position of the first layer (I tried to nail the first before doing others) and also a slider to keep a constant basic movement so then my expression looked something like this...


      temp = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");


      newt = (effect("Slider Control")("Slider")) + (temp) + 20;


      cool = 1080;




      (I have no clue why I named them newt and cool that was what I heard when typing so there's that )


      Anyways, I thought I had this all worked out and it was going to be a simple piece of diddlydonk (do people say that? ) when my layer (a bunch of stars) started jumping back and forth when I asked the rig to play me a RAM preview. I was confused as to why it was doing this - then it hit me.


      As it turns out, my audio amplitude keyframes generated from the bass-y audio jumps up and down (as expected) so the temp value goes up and down resulting in jerky movement. My question is is there any way to make the keyframes cumulative in value or some other way to achieve the effect that I want. Feel free to ask more questions and btw project size is 3840x2160 @60fps (like a baus!) and basic movement is 1.5px/frame or 90px/s and I'm a complete noob to expressions and code so please take it easy on me


      Many thanks to any cool people who are awesome at expressions and can understand this

        • 1. Re: Increase expression variable using a slider in a separate layer?
          Rick Gerard Adobe Community Professional & MVP

          Couple of comments here. Your comp is huge and is probably never going to playback at 60 fps unless you have a monster machine. You should take some time to learn about video standards and frame rates. 29.97 HD is the universal standard and if you are pushing your project to YouTube 99% of all users will not be able to playback anything else. YouTube will also re-compress your footage to 29.97 fps so you are not gaining anything by working in large comp sizes. Working in 4K requires extensive knowledge and understanding of the entire production to playback process. Just jumping in and deciding you are going to produce in 4K or any other CUSTOM comp size is asking for problems.


          When you are messing with audio to keyframes the first thing you need to do is open up the graph editor and take a look at the range of values. Let's say they go from 0 to 20. Now that you know the range you can figure out where you want the trigger to start running your effect and what values you want to use. Then you add an expression that uses ease or linear to translate the values to something usable. For example, let's say you wanted to animate the position of a star made from a shape layer. The polystar will have x and y values for the poly star transform and the layer will also have transform property x and y values. Personally I would use the Polystar 1 Transform Position property. There will be an initial position (value) and you have decided that you want to change the y position by a maximum of 200 pixels. You also want the star to stay the same size until a minimum value of 10 is achieved so all the rumbling and extraneous noise isn't going to make it wiggle around so much. Here's the expression:

          t= thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider"); // audio value

          y = value[1] + linear(t, 10, 20, 0, 200);

          x = value[0];

          [x, y]


          This expression adds a number between 0 and 200 to the original value of y and maintains the original value of x. You can change linear to ease to smooth things out a bit.


          Another approach would be to add the smooth method to the position value. Smooth works by referencing keyframes with two numbers. The first is width in seconds, the second is the number of samples. The expression for that would look like this:


          smooth(.1, 6)


          The only problem is that the first expression does not add keyframes. You would have to covert the first expression to keyframes with the Keyframe Assistant and then replace the expression. You could apply the smooth method to Both Channels in the Audio Amplitude layer and avoid converting the first expression to keyframes. The only way you can really tell what's going on is to look at the Graph Editor as you manipulate the values.

          Screen Shot 2016-06-10 at 10.08.56 PM.png

          You should spend some time researching expression language by typing expression in the Search Help field at the top right corner of AE and you should also seriously consider a naming convention for your variables so you can figure out what you were trying to accomplish.


          If these solutions don't work for you you'll have to take your audio into Audition and manipulate it and render another copy so you get a more responsive waveform with smoother peaks and valleys. You use the manipulated audio for driving your expression only, you don't replace the original.