Level Discoverystart here Intermediatethe architecture Expertin depth
Expert ยท Batch 5 ยท Storm
Chapter 5 ยท expert level

The right moment, not just the right sound

The finishing touch of procedural sound: chaining two ambiences without cutting a gust by waiting for a lull, then the per-biome soundtrack and its round transition โ€” crossfading the volumes and gliding the tempo along the same curve.

1Cycling without cutting a gust

In random play, each character plays for a while, then another takes over. Since wind is a continuous loop, we avoid cutting it mid-swell: once the duration elapses, we wait for a lull (a dip in level) before switching, with a crossfade of about 1.4 s. A 2.5 s cap guarantees it always eventually changes.

the character switch, timed to a lull
// has the duration elapsed?
if (!swapPending) {
  if (now >= cycleAt) { swapPending = true; pendingSince = now; }
} else if (rms() < 0.05 || now - pendingSince > 2.5) {
  swap(pickOther(), 1.4);   // gentle crossfade to another character
  cycleAt = now + 8 + Math.random() * 5;
}

The result: you never hear a gust cut off abruptly โ€” the transition slips into the wind's relative quiet.

The moral. Good procedural sound isn't only synthesis: it's also when you trigger things. Waiting for the right moment often beats a longer fade.

2Per-biome soundtrack โ€” proposals & round transition

Turn the sound on: everything is synthesized live, no audio files.

Each biome has its own sonic climate, offered in several proposals. During a match, a biome's two ambiences alternate from round to round; the final round has its own music. When the scene slides to the next hill, the music follows: a crossfade of the volumes and a tempo glide (BPM) along the same smoothstep curve, so both tracks stay in sync through the transition.

The catalog keeps every proposal โ€” including the five Desert ones. The mixer plays the playlist chosen per biome (Desert: Mirage and Fournaise in rotation, Simoun for the finale). Pick a biome, then run through the rounds.

โ˜…And that wraps up the notebook!

From the game loop to synthesized sound, you've made the full tour of Tower Duel.

Five batches, three reading levels, a handful of simulators: you now know how a small web game comes to life, screen after screen, gust after gust. Thanks for reading all the way through.

โ†ฉ Back to home

โ† Chapter 4 ยท Destructible terrain The end ๐ŸŽ‰