Activity › Forums › Adobe After Effects Expressions › Audio sound effects follow type
-
Audio sound effects follow type
Posted by Nihad Spahic on October 28, 2025 at 9:01 amHey guys, is it possible to have audio follow text animation?
I have created a “humanized” typing effect and would love to have, for example, 4,5 variations of typing sound which would follow text animation and space key sound where space appears. Is there a workaround for this? Cheers!Nihad Spahic replied 6 months, 2 weeks ago 2 Members · 2 Replies -
2 Replies
-
Dan Ebberts
October 28, 2025 at 9:48 pmYou could do something like that with a time-remapped precomp that has all your sound effects arranged at different times and a time remapping expression that plays the sounds in response to typing “events”. The implementation would depend on how you have your type animation set up and what info the expression has available to trigger the different sounds.
-
Nihad Spahic
October 29, 2025 at 7:39 amSo I have this expression with help of Ai on the text and it works really good.
// Human-like typing with total duration control + blinking cursor + start delay
txt = value.toString(); // full text
dur = comp("Main Comp").layer("General Settings").effect("Duration")(1); // total typing duration (seconds)
delay = comp("Main Comp").layer("General Settings").effect("Delay")(1); // delay before typing starts (seconds)
jitter = 1; // randomness factor (0 = uniform, 1 = irregular)
blinkRate = 3; // cursor blink frequency
t = time - inPoint - delay; // <-- delayed start
seedRandom(index, true);
total = txt.length;
baseStep = dur / total;
typed = 0;
elapsed = 0;
for (i = 0; i < total; i++){
step = baseStep * random(1 - jitter, 1 + jitter);
elapsed += step;
if (elapsed < t) typed++;
}
// keep text invisible until delay is over
if (t < 0) typed = 0;
visible = txt.substr(0, typed);
// blinking cursor
showCursor = (Math.floor(time * blinkRate) % 2 == 0) ? "|" : " ";
visible + showCursor;And this expression is on the time remap with 5 keyboard sound fx isolated that are 15 fps long and one after each other with space bar sound fx on the beginning.
// --- Link to the Text Layer ---
var textLayer = thisComp.layer("Helo world 3"); // <-- Make sure this layer name is correct!
// --- Your Custom Audio Settings ---
var numRegularSounds = 5; // <-- UPDATE: The number of REGULAR key sounds.
var soundDurationFrames = 15; // <-- UPDATE: The duration of ONE sound slot in frames.
// --- Expression Logic (No need to edit below this line) ---
var soundDuration = framesToTime(soundDurationFrames);
try {
var currentLength = textLayer.text.sourceText.length;
var prevLength = textLayer.text.sourceText.valueAtTime(time - thisComp.frameDuration).length;
if (currentLength > prevLength) {
// A new character was just typed. Check what it is.
var newChar = textLayer.text.sourceText.value.charAt(currentLength - 1);
if (newChar == " ") {
// It's a spacebar. Play the first sound.
0; // Start time of the spacebar sound.
} else {
// It's a regular key. Pick a random sound from the regular keys section.
seedRandom(currentLength, true);
var randomSoundIndex = Math.floor(random(numRegularSounds));
var soundStartTime = soundDuration + (randomSoundIndex * soundDuration); // Offset by the spacebar sound.
soundStartTime;
}
} else {
// No new character, continue playing the last triggered sound.
var timeOfLastCharacter = time;
var lengthAtTime = currentLength;
while (lengthAtTime >= currentLength && timeOfLastCharacter > 0) {
timeOfLastCharacter -= thisComp.frameDuration;
lengthAtTime = textLayer.text.sourceText.valueAtTime(timeOfLastCharacter).length;
}
timeOfLastCharacter += thisComp.frameDuration;
var timeSinceLastKey = time - timeOfLastCharacter;
if (timeSinceLastKey < soundDuration) {
// Continue playing the sound that was triggered.
var lastCharIndex = textLayer.text.sourceText.valueAtTime(timeOfLastCharacter).length;
var lastChar = textLayer.text.sourceText.valueAtTime(timeOfLastCharacter).charAt(lastCharIndex - 1);
var lastSoundStartTime;
if (lastChar == " ") {
lastSoundStartTime = 0;
} else {
seedRandom(lastCharIndex, true);
var lastRandomSoundIndex = Math.floor(random(numRegularSounds));
lastSoundStartTime = soundDuration + (lastRandomSoundIndex * soundDuration);
}
lastSoundStartTime + timeSinceLastKey;
} else {
// Sound has finished, jump to a silent part.
thisLayer.source.duration;
}
}
} catch (e) {
// Error fallback.
thisLayer.source.duration;
}
It doesnt understand the delay and also its somehow chunky weird noises even tough on each sound FX there is a pause on the begining and in the end
Thanks in advance!
Reply to this Discussion! Login or Sign Up