# Trigger Sounds and Animations by Markers in After Effects

Animating stuff that pops on and off of the screen in After Effects can become a pain as you'll have to either create several instances (cluttering up your comp) or create countless keyframes to toggle the layer's opacity.

To ease the process of event-driven repetition, we put together two expressions for the time remap channel of compositions and sounds.

In short, our expressions tells After Effects to "play a sound (or the content of a composition) every time we hit a marker."

Let us walk through two examples to clarify the benefit of using the presets at the end of this article.

## Example 1: Cars Passing by: Sound Driven by Markers

First, we created a marker any time a car was passing by in the footage. Then we hooked in the expression in the time remap channel and the sound was good to go. If we would have just copied the layer and positioned it, the timeline would have been way more clogged up and harder to manage:

Sounds Inserted Manually

Sounds Evoked by Marker: So Clean!

As you can see in the timeline of the video, we animated the value of Pan as well, in order to create the impression the sound moves from left to right.

## Example 2: 3D Typewriter: Animation & Sound Driven by Markers

Of course, both techniques can be combined to drive both video and audio using Time Remap.

Using Element 3D for After Effects and a customized 3D model from Google's Warehouse, we created a procedural typewriter rig. Equipped with a variety of expression controls, we were able to simply change the source text attribute to switch out the text, still resulting in a finished animation with the right sounds being adjusted automatically. Markers on the control layers would allow us to change the timing of the keystrokes (see fig. IV).

The whole magic behind the expression is merely mapping the length of the audio clip to the position of the markers and turning the current time into time remap values, as depicted here:

Figure IV: Explanation of Expressions

Using linear, our expression transposes the distance to the last marker into a sequence between 0 and the length of the audio clip, in our case 50. With the values needed for the first marker of our example, this would lead to the following use of linear:

## Conclusion

The expressions come in handy particularly when animating guns, muzzle flashes and so on.

Download the following two presets for simple drag-and-dropping of the expressions and controls: