Skip to content
A red audio waveform along the bottom driving four layer bars above it, lit where the waveform peaks and dim where it falls quiet
Back to blogtutorials

How to Trigger Layer Visibility with Sound in After Effects

ANFX 2018-06-10 5 min read

Make layers appear on every beat in After Effects: Convert Audio to Keyframes, one opacity expression, and how to pick the right amplitude threshold.

You have a music track and a layer that needs to flash on every beat — a logo, a strobe frame, a lyric. Hand-placing an opacity keyframe on each hit takes an hour for a three-minute song, and the moment the edit shifts by ten frames, all of them are wrong. The fix is to let the audio drive the layer directly: convert the track’s loudness into keyframe data once, then use a two-line expression to switch the layer on whenever the level crosses a threshold.

The whole rig takes about five minutes to build and survives any re-edit of the music.

Step 1: Convert Audio to Keyframes

Expressions can’t read a waveform directly — they need the audio as numeric keyframes first.

  1. Select the audio layer in your comp.
  2. Go to Animation > Keyframe Assistant > Convert Audio to Keyframes.
  3. After Effects creates a null layer called Audio Amplitude with three effect sliders: Left Channel, Right Channel, and Both Channels.

The Both Channels slider now holds one keyframe per frame, each storing the track’s loudness at that moment. Select the slider and press the graph editor button to see the song as a curve — you’ll use this view in a minute to pick your threshold.

If your music is embedded in a video file, extract it first — the free MP4 to WAV converter gives you a clean audio file to drop into the comp.

Step 2: The Visibility Trigger Expression

Alt-click (Option-click on Mac) the stopwatch on your target layer’s Opacity and paste:

threshold = 15;
audio = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
audio > threshold ? 100 : 0;

Read it plainly: sample the audio level this frame; if it’s louder than 15, opacity is 100; otherwise 0. The layer now hard-cuts on with every hit that clears the threshold — no keyframes on the layer itself.

To invert the behavior — a layer that hides on each beat — swap the last line to audio > threshold ? 0 : 100;.

Step 3: Pick the Right Threshold

The threshold number is the entire feel of the effect, and there is no universal value — it depends on your track’s mix.

Open the Audio Amplitude graph and look at the curve. Kick drums on a typical music track peak somewhere in the 20–50 range while the bed of the mix sits under 10, but a quiet acoustic track might peak at 12. Set the threshold just below the peaks you want to catch and above everything you don’t:

  • Threshold too low: the layer stays on almost constantly.
  • Threshold too high: it never fires.
  • Threshold in the gap between peaks and bed: clean, distinct triggers.

Scrub the timeline and adjust the number live — the expression updates immediately.

Beyond On/Off: Values That Pump with the Music

Hard visibility cuts suit strobes and glitch frames. For smoother audio reactivity, feed the same slider through linear() instead of a threshold. On Scale:

audio = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
s = linear(audio, 0, 25, 100, 130);
[s, s]

As the audio level moves from 0 to 25, the layer scales from 100% to 130% — a logo that breathes with the bassline. The same pattern drives Opacity, glow intensity, or any effect slider, and it’s the technique behind every music visualizer. If you want the full spectrum-bars version without building it, the free YouTube audio visualizer walkthrough covers that route.

A classic combo: trigger a distortion layer’s visibility on each beat so the frame “damages” in time with the music. Drop the free 4K glitch overlays above your footage, set the blend mode to Screen, and put the threshold expression on the overlay’s opacity — beat-synced glitches with zero manual keyframes. The from-scratch version of that distortion look is in how to create a glitch effect in After Effects.

Fixing the Two Common Failures

The expression errors with “layer not found.” The layer name in quotes must match exactly — if you renamed the null, or it lives in a different comp than the target layer, the reference breaks. Both layers must be in the same comp, or you must reference the comp by name.

The trigger flickers rapidly around the threshold. When the audio level hovers near your threshold, the layer can toggle every frame. Smooth the input by replacing the second line with:

audio = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider").smooth(0.1, 5);

smooth() averages the value over a small time window (here 0.1 seconds, 5 samples), which kills single-frame chatter while keeping the beats intact.

FAQ

Why don’t I see an Audio Amplitude layer after converting?

Convert Audio to Keyframes only works on a layer that actually contains audio, selected in the timeline. If you ran it with nothing selected, or on a video layer whose audio is muted or absent, nothing useful is generated. Select the audio layer itself and run the keyframe assistant again.

Can I trigger a layer only on the bass, not the whole mix?

Yes. Duplicate the audio layer, apply a low-pass EQ so only the low end remains (Effect > Audio > Bass & Treble, treble fully down, works in a pinch), then run Convert Audio to Keyframes on that filtered duplicate. Point your expression at the new Audio Amplitude null and it responds to kick and bass only.

Does this work with voice-over instead of music?

It works with any audio — the amplitude keyframes don’t care what the sound is. Speech has a spikier, less regular envelope than music, so use smooth() on the slider and expect triggers on syllables rather than a steady rhythm. It’s a quick way to make a mouth graphic or waveform icon react to dialogue.

Why is my layer triggering slightly after the beat?

Convert Audio to Keyframes samples per frame, so at 30 fps a trigger can land up to one frame late — usually invisible. If it reads late, offset the sample time by replacing ("Slider") with ("Slider").valueAtTime(time + thisComp.frameDuration) to look one frame ahead, or slide the audio layer one frame earlier.

Enjoy this article?

Share it with your creative community and help others discover great content.