Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Mute Audio at Markers Expression

Tagged: 

  • Mute Audio at Markers Expression

    Posted by Dustin Mans on September 17, 2020 at 1:00 pm

    Hello, how to change the audio levels from (0 to -192) with markers?

    Audio level mutes for 5 seconds at Marker

    m=thisComp.marker;
    n = 0;
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    }
    if (n > 0){
    t = time - m.key(n).time;
    if (Math.abs(t) <= 5*thisComp.frameDuration) 100 else 0
    }else
    value

    Audio level mute between Markers

    if (marker.numKeys > 0){
    m = marker.nearestKey(time);
    t = m.time;
    if (m.index%2){
    ease(time,t,t+2*thisComp.frameDuration,100,0)
    }else{
    ease(time,t,t+3*thisComp.frameDuration,0,100)
    }
    }else{
    value
    }
    Dustin Mans replied 5 years, 7 months ago 5 Members · 7 Replies
  • 7 Replies
  • Stephen Dixon

    September 18, 2020 at 2:18 am

    A little bit hard to understand what you’re asking. Maybe explain exactly what you want to do.

  • Dustin Mans

    September 18, 2020 at 4:34 am

    Turn the sound on and off with an expression, similar to triggering the Opacity on /off with markers. Star Struck

  • Andrei Popa

    September 18, 2020 at 5:24 am

    I think you can use the same expressions, just replace 100 and 0 with 0,-192

    m=thisComp.marker;
    n = 0;
    if (m.numKeys > 0){
    n = m.nearestKey(time).index;
    }
    if (n > 0){
    t = time - m.key(n).time;
    if (Math.abs(t) <= 5*thisComp.frameDuration) 0 else -192
    }else
    value
    if (marker.numKeys > 0){
    m = marker.nearestKey(time);
    t = m.time;
    if (m.index%2){
    ease(time,t,t+2*thisComp.frameDuration,0,-192)
    }else{
    ease(time,t,t+3*thisComp.frameDuration,-192,0)
    }
    }else{
    value
    }
  • Stephen Dixon

    September 18, 2020 at 5:27 am

    Those expressions you posted both do what you want, they turn the sound on and off with markers. But I’m guessing when you say on and off, maybe you want the sound to start at one marker and end at the other? If so use the second expression, but invert the logic—it currently turns the audio OFF if the current time is between two markers, so you want to do the opposite; turn the audio ON if the time is between two markers.

    To invert the logic you could either swap the contents of the curly brackets (the two lines starting with ease…) or add a logical not to the if() using the javascript notation !. in other words, line 4 should be if(! m.index%2){

  • Dustin Mans

    September 18, 2020 at 6:42 am

    An error tells me the code needs to modified to be two dimensions?

  • Filip Vandueren

    September 18, 2020 at 10:59 am

    Ah yes, makes sense for L/R stereo audio

    replace 0 and -192 with [0,0] and [-192,-192]

  • Dustin Mans

    September 18, 2020 at 11:45 pm

    Thanks they are working!

    How to edit this expression to use comp markers instead of the layer markers?

    if (marker.numKeys > 0){
    m = marker.nearestKey(time);
    t = m.time;
    if (m.index%2){
    ease(time,t,t+2*thisComp.frameDuration,0,-192)
    }else{
    ease(time,t,t+3*thisComp.frameDuration,-192,0)
    }
    }else{
    value
    }

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