Skip to main content
Qristian
Inspiring
June 21, 2019
Answered

How to enable/disable an audio track

  • June 21, 2019
  • 2 replies
  • 6081 views

Hi.

I have a sequence in AE with several audio tracks, and I want to be able to choose one of them and enable it, disabling the others. Is it possible? How would you guys do it?

Thanks!!

Correct answer Justin Taylor-Hyper Brew

In that case, create a Control Null, add a slider to it, and then add this expression to the Audio Levels of all the audio layers:

thisLayer.index == thisComp.layer("Null 1").effect("Audio-Selector")("Slider") ? value: [-192,-192];

This will compare the index to the layer selected. If they're equal, it will use the value you have set. If not, it will mute the layer by setting its level to -192dB.

2 replies

Inspiring
March 17, 2023

I found one solution! 

Add Stereo Mixer and Checkbox Control to the Audio Layer. Then add this expression to both left and right channels of the Stereo Mixer:

 

if(effect("Checkbox Control")(1)==1) {100} else {0}

 

It's the same solution with checkbox for opacity.

jaredm71592015
Inspiring
March 17, 2023

This is a sufficient way to set the audio to be on or off just like the audio level code using the -192db method.  Testing this is magical as long as you are in the same comp but as soon as you try to use Essential Graphics this no longer works. It only plays the audio track that is set as the initial default value, no matter what you do to try and change that value through Essential Graphics it will not change. Using the opacity on different videos will work passing the variable values but not audio.  This is the issue we need Adobe to address and rectify.  Not sure what the backend code is that makes it work for video but not audio it becomes frustrating having to duplicate the same animation several times just for an audio change, and then when you have to make small tweaks and changes you have to duplicate your changes that many times as well.  We need to band together to have adobe help us work smarter not harder. So as long as you are staying within the same comp this method will be fantastic. You can clean the code up to be as simple as on the audio channels just add this: effect("Checkboc Control")*100 ;

Justin Taylor-Hyper Brew
Community Expert
Community Expert
June 21, 2019

The Solo checkbox will only show that audio layer if that's what you're after.

If you want the others to stay muted, then you can simply select all the layers (Cmd + A / Ctrl + A) and then click the audio checkbox so they're all turned off, then turn on the one you want.

Also, since you're posting this in the Expressions forum, are you after an expression approach to this? If so can you elaborate more?

Qristian
QristianAuthor
Inspiring
June 21, 2019

Yes, thanks.
I need to control this with an expression. Hopefully, to control which track is enabled at the time by selecting a number with a slider.

And I need to have it this way because I want to export this sequence as an Essential Graphics.

Justin Taylor-Hyper Brew
Community Expert
Community Expert
June 21, 2019

In that case, create a Control Null, add a slider to it, and then add this expression to the Audio Levels of all the audio layers:

thisLayer.index == thisComp.layer("Null 1").effect("Audio-Selector")("Slider") ? value: [-192,-192];

This will compare the index to the layer selected. If they're equal, it will use the value you have set. If not, it will mute the layer by setting its level to -192dB.