Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Fade audio in/out based on layer’s in/out points

  • Fade audio in/out based on layer’s in/out points

    Posted by Bryan Woods on December 29, 2014 at 10:44 pm

    Can’t seem to find anything on this. I use my layer opacity fade script but can’t apply it to audio. Gives me an error that it must be a dimension of 2, not 1. But the output is a single value isnt it? Here’s what I typically use below for opacity that I want to adapt to audio as well:

    transition = effect("Transition Duration")("Slider"); // transition time in frames
    if (marker.numKeys<2){
    tSecs = transition / ( 1 / thisComp.frameDuration); // convert to seconds
    linear(time, inPoint, inPoint + tSecs, 0, 100) - linear(time, outPoint - tSecs, outPoint, 0, 100)
    }else{
    linear(time, inPoint, marker.key(1).time, 0, 100) - linear(time, marker.key(2).time, outPoint, 0, 100)
    }

    Bryan Woods replied 11 years, 7 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    December 29, 2014 at 11:41 pm

    Something like this maybe:


    transition = 2;
    minVal = [-48,-48];
    maxVal = [0,0];
    if (time < (inPoint+outPoint)/2){
    linear(time,inPoint,inPoint+transition,minVal,maxVal);
    }else{
    linear(time,outPoint-transition,outPoint,maxVal,minVal);
    }

    Dan

  • Bryan Woods

    December 29, 2014 at 11:56 pm

    Thanks Dan. Thats what i’m looking for. I modified it slightly though to not use seconds but frames. The modification I made seems to work only briefly. Once I scrub through the timeline, the expression throws a warning:

    “Property or method “tSecs” in class “global” is missing or does not exist.”

    here’s my mod to your code below. Error happens on line 8, but i can’t figure out why:


    transition = effect("Transition Duration")("Slider"); // transition time in frames
    minVal = [-48,-48];
    maxVal = [0,0];
    if (time < (inPoint+outPoint)/2){
    tSecs = transition/(1/thisComp.frameDuration);
      linear(time,inPoint,inPoint+tSecs,minVal,maxVal);
    }else{
      linear(time,outPoint-tSecs,outPoint,maxVal,minVal);
    }

  • Dan Ebberts

    December 30, 2014 at 12:05 am

    I think you just need to move your tSecs definition above the if statement (otherwise it’s not defined when you get into the else clause).

    Dan

  • Bryan Woods

    December 30, 2014 at 12:13 am

    Yup! That was the issue. Thanks again Dan for your help. I really appreciate your continued efforts here.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy