In this post, you will learn how to create an audiometer using text and expressions in After Effects.
By the way, just a little disclaimer: I will not be able to show you how to set up everything you see in this composition, however, you can download the project file and follow along!
With that said, In this tutorial, I will show you the most important parts you should know and you will be able to pick it up from there.
So for this example, I have an audio level.
I am going to convert the waveform from the image above into numbers, that way I can actually use them.
To do that, I am going to right-click on the [AUDIO SAMPLE.wav] and go to Keyframe Assistant – Convert Audio to Keyframes.
You should now see a new [Audio Amplitude] layer appear and a null in our composition.
Press U on the keyboard to see all of the keyframes.
As you can see, it gave us the Left Channel, the Right Channel and Both Channels.
I am going to get rid of the Right and Left Channels by first selecting them and then pressing delete.
I now only have Both Channels.
Next, I am going to create a text in my composition. So I am going to write just something like value inside of my composition, but you can write anything you want.
And I am going to go inside the value text layer and select its Source Text.
Hit S twice on my keyboard to solo it.
Then I will click on the stopwatch icon to activate the expression.
Now I am going to set some variables inside of the text box.
First, I am going to say, audio you are going to be and then I will pick-whip to the [Audio Amplitude] slide like so:
audio = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
This will create a random variable, I will call it n and n will equal an empty string.
audio = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
n = “”;
Next, I am going to do a For loop.
So I am going to say for() and inside of the parenthesis, I am going to say i = 0 and then as long as i is less than audio, we are going to run an expression. Lastly, we are going to increase i by one with each loop. Then we will write our expression inside of the curly brackets.
audio = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
n = “”;
for(i=0; i<audio; i++){
}
Inside of the curly brackets, I am going to say n, you are going to += i.
audio = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
n = “”;
for(i=0; i<audio; i++){
n += i;
}
Stay with me! I hope I did not confuse you there. Let’s now see what happens.
As you can see, in a way it created like an audiometer. So if I drag through it with my time indicator, you can see it is kind of interesting, but what happens if we replace this i for like a string, maybe a lowercase L.
audio = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
n = “”;
for(i=0; i<audio; i++){
n += “l”;
}
So now it looks more like an audiometer! It does not show random numbers anymore like it did in the previous example. Instead, it displays lowercase L, which looks a lot like an audiometer!
Let’s keep going. Because the string is text, now we can go into these Character Options and play with them.
We can bring text closer together.
We can make it fatter.
Or skinnier.
So as you can see, the sky’s the limit with what we can do here but I think where I am at right now is probably fine.
Another cool thing about this is that we can disable the expression.
and type lowercase L 15 times.
The reason why I entered lowercase L 15 times because that is how long I want the audiometer to be.
I can now activate the expression again.
A it will now take a value between 0 and whatever the highest one here, which is something between 18 and 19. Then it will create these bars.
But how can I restrict it to where it only goes up to a certain number? Let me show you.
I am going to type a Linear Expression, so I am going to say audioFix you will be linear() and I will plug in the audio inside of the parenthesis. I also want 0 to be my minimum value and I also want it to go up to 20 just to be safe. So it is going to go between 0 and 20. It will not go any higher or lower.
audio = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
audioFix = linear(audio, 0, 20)
n = “”;
for(i=0; i<audio; i++){
n += “l”;
}
And then I want to convert it from 0 to 15 because we have 15 bars. So it will not go more than 15 bars. That should be good.
audio = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
audioFix = linear(audio, 0, 20, 0, 15);
n = “”;
for(i=0; i<audio; i++){
n += “l”;
}
Then where it says audio in our code, I want to change that to audioFix like so:
audio = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
audioFix = linear(audio, 0, 20, 0, 15);
n = “”;
for(i=0; i<audioFix; i++){
n += “l”;
}
If I let go, it is still going to do the same thing but this time it is going to stay within 0 and 15 bars.
So you definitely get an idea of how to set something like this up. You can keep altering things as you like. For example, you can say instead of 0 maybe you want to start at like 5 and it is going to start at 5 and go up to 20.
audio = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
audioFix = linear(audio, 5, 20, 0, 15);
n = “”;
for(i=0; i<audioFix; i++){
n += “l”;
}
So you can kind of adjust which peaks you want and how many bars you want. You can also change 15 to say 25 and now we are seeing a lot more bars in our audiometer.
audio = thisComp.layer(“Audio Amplitude”).effect(“Both Channels”)(“Slider”);
audioFix = linear(audio, 5, 20, 0, 25);
n = “”;
for(i=0; i<audioFix; i++){
n += “l”;
}
This thing is definitely not perfect but I just want to show you how awesome expressions are and just another way to create an audiometer using text.
I hope you found this post useful. If you would like to learn more about Expression and how it can speed up your workflow in After Effects, check out my Learn After Effects Expressions Course.