wiwis.dev

Gunshots without recordings: how Warfront makes its shots

· Warfront

The blue team's tank in Warfront at its base, next to the tents, with the blue marking on its turret

Warfront doesn't contain a single sound file. Not one recording of a rifle, a footstep or a cannon. When the game starts, every gunshot is computed sample by sample, meaning value by value, at tens of thousands of values per second of sound. The result is stored in memory, ready to play with every shot. Here's the recipe.

Why a gunshot is a complicated sound

A real gunshot isn't a single noise but several events that follow each other within a few milliseconds. The powder gases burst out of the barrel all at once and create a violent pressure wave: the muzzle blast. The bullet, traveling faster than sound, makes its own sharp crack. The weapon's action clicks. Then the sound travels out across the landscape and comes back, bounced off hills, walls and trees, as echoes that roll on for more than a second.

Plain white noise cut off abruptly gives you a "pssht" that sounds like nothing at all. To get a believable shot, Warfront stacks several layers, each one computed separately, then mixes them together.

The recipe, layer by layer

1. The blast

This is the attack of the sound: 30 milliseconds of noise that rises in under a tenth of a millisecond and falls off within two milliseconds. Right after, around 4.5 milliseconds in, the signal dips below zero for a brief moment. That dip mimics the negative pressure phase that follows any shock wave: the air, violently pushed away, rushes back. On its own, it's a detail the ear can't pick out, but it gives the shot its physical punch.

2. The thump

Beneath the blast, a low tone sweeps from 190 down to 58 hertz and dies out in about fifty milliseconds. It's the push of the gases, something you feel in your chest more than you hear.

3. The crack

The bullet's sharp crack is noise filtered around 1,900 hertz, dying out in sixteen milliseconds. A fourth, very subtle layer adds a high-pitched sizzle above 4,500 hertz for texture.

4. The action

For their own rifle, the player also hears the bolt: two metallic clicks, at 38 and then 71 milliseconds after the shot. Each click is made of three high-pitched vibrations, between 2,650 and 6,200 hertz, that die out within a few milliseconds, like a small piece of metal being struck. Other soldiers' shots don't have this detail: you'd only hear it up close.

5. Early echoes

The first sixty milliseconds of the shot are copied four times, each one later and quieter: at 45, 90, 150 and 240 milliseconds. Each copy is muffled, because the surfaces that reflect sound mostly absorb the highs. A touch of randomness shifts each echo by a few milliseconds, so no two shots ever have exactly the same acoustics.

6. The rolling tail

Finally, a long, muffled noise stretches out over more than a second. Its volume wavers slightly and its highs fade out gradually: it's the rumble that rolls across the battlefield after every shot.

7. The mix

All the layers are summed, stripped of inaudible lows and extreme highs, then lightly saturated to give them body, before a short fade at the end. The game builds several versions of each sound: four for the player's own rifle, four for a nearby shot, three for a distant shot and two for the tank cannon. It never plays the same one twice in a row, and it slightly changes the playback speed with every shot. The ear never hears a mechanical repetition.

Distance: sound travels at 343 meters per second

Warfront's most striking detail is the delay on distant shots. The game measures the distance between the player and the shooter and delays the sound accordingly: a shot at 100 meters arrives almost three tenths of a second after the muzzle flash, a shot at 300 meters nearly a full second after. That's exactly what you notice in real life with a thunderstorm or fireworks.

Distance also changes the color of the sound. The farther away the shooter, the more the highs are cut: around 5,000 hertz at 100 meters, around 2,000 hertz at 300 meters. Beyond 70 meters, the game switches to a distant version of the shot, longer and more muffled, with more widely spaced echoes. The volume drops with distance, and the sound is panned left or right depending on the shooter's direction. The player's own shots are played "inside the head," with no delay or filtering.

In the thick of battle, up to twenty-eight sounds can overlap. A compressor at the end of the chain keeps the gunfire from clipping.

Footsteps, grain by grain

Footsteps are made the same way, with no recordings. Each step is a cloud of tiny noise grains, scattered at random and then filtered according to the ground: grass, dirt, stone, sand or wood. Stone adds a small metallic "tick," wood a low resonance around 150 to 210 hertz, like a plank ringing underfoot. The game computes these sounds on a separate thread so they don't slow down startup.

A step lands every 2.1 meters when walking and every 2.6 meters when sprinting, using the material of the block or ground underfoot. Other soldiers' footsteps fade out completely beyond 24 meters.

What you don't hear

Warfront has no music, no engine noise and no explosion sound: shells burst in a cloud of particles and a screen shake, in silence. Only the cannon's firing gets its own version, deeper and longer. This choice leaves all the room to the two sounds that matter for gameplay: gunshots, which tell you where the enemy is and how far away, and footsteps, which give away anyone sneaking up on you.

The same synthesis approach is what makes Superkart's karts roar: a two-stroke engine computed entirely in code.

Play WarfrontGame page

Read next