Procedural Audio Synthesis: 2,445 Lines of Sound With Zero Audio Files
Dreadnought ships with 99 distinct sound effects — alien screams, reactor hums, metal groans, boss roars, spatial footsteps through walls. None of them come from audio files. Every sound in the game is generated at runtime from raw waveforms using Love2D’s SoundData API. No WAVs, no MP3s, no asset pipeline. Just math.
This is the story of how an AI agent built a complete procedural audio engine for a survival horror game, and what it reveals about the future of zero-asset game development.
Why Procedural Audio
The Dark Factory operates under a hard constraint: no external assets. Every game in the studio — Polybreak, Chronostone, Voidrunner, Dreadnought — generates all its content at runtime. Graphics are drawn with code. Music is synthesized from waveforms. Sound effects are mathematical functions that output sample buffers.
This isn’t a stylistic choice. It’s an architectural decision driven by how the factory works. AI agents writing code can iterate on procedural generation instantly. They can’t easily source, license, edit, and integrate binary audio files. Procedural audio turns sound design into a software engineering problem, and software engineering is exactly what these agents do.
The constraint paid off. Dreadnought’s audio system spans 2,445 lines of Lua — roughly 8x larger than any other game in the factory. It implements waveform synthesis, frequency modulation, cascaded filtering, spatial positioning, and ten unique ambient soundscapes. All from scratch, all in code.
The Synthesis Stack
Every sound in the engine starts from five fundamental waveforms:
- Sine: Pure tones for drones, melodic elements, and sub-bass
- Square: Duty-cycle modulated for harsh, buzzing timbres
- Sawtooth: Harmonically rich for textured pads and sweeps
- Triangle: Smooth oscillation for gentle tones
- White noise: Filtered and shaped for organic ambience, sizzle, and breath
These are combined through additive synthesis and modulation to produce complex sounds. A single effect might layer six harmonic sine waves at ratios of 0.5x, 1x, 1.5x, 2x, 3x, and 6x the base frequency, each with independent phase tracking and amplitude envelopes.
Frequency Modulation
The engine uses FM synthesis for metallic, bell-like, and alien tones. A modulator oscillator controls the frequency of a carrier, producing sidebands that create complex spectra from simple inputs. The alien screech effect, for example, sweeps a carrier from 400 Hz to 1000+ Hz while a second oscillator warbles the pitch at 7 Hz — producing an unsettling, organic wail.
Envelope Shaping
Sounds need shape over time, not just frequency content. The system implements multiple envelope types:
- Exponential decay:
math.exp(-t * factor)for metallic pings and percussive hits - Bell curves:
sin(pi * fraction)for gentle pad swells - Quadratic rolloff:
(1 - frac)^2for fast attacks with lingering sustain - Piecewise custom: Multi-segment envelopes for gate pulses and stutter effects
The combination of waveform selection, harmonic layering, FM modulation, and envelope shaping gives the system enough range to cover everything from a gentle keycard chime to a multi-layered boss roar.
Spatial Audio: Sounds That Know Where They Are
Dreadnought is a top-down survival horror game with cone-of-vision mechanics. Sound plays a critical role — you hear threats before you see them. The spatial audio system makes this work.
The playAt() function takes a sound source and two positions: the emitter (an alien, a vent, a sparking wire) and the listener (the player). It computes:
- Euclidean distance between emitter and listener
- Quadratic falloff: volume scales as
(1 - dist/maxDist)^2, approximating the inverse square law - Angle-relative panning: the angle between emitter direction and player facing determines stereo placement via OpenAL 3D positioning
- Distance cutoff: sounds beyond max range don’t play at all, saving CPU
The result is that alien footsteps get louder as they approach, distant screams echo faintly from the correct direction, and reactor hums fill the space around you. All computed per-frame with clone-based audio pooling to prevent playback artifacts.
Cascaded Filtering: Hearing Through Walls
One of the most effective techniques in the system is cascaded low-pass filtering for muffled sounds. When an alien walks on the other side of a wall, you shouldn’t hear crisp footsteps — you should hear a dull, ominous thud.
The engine implements this with progressive filtering stages:
Single-pole: (sample + prev) * 0.5
Double-pole: (sample + prev1 + prev2) / 3
Triple-pole: (sample + prev1 + prev2 + prev3) / 4
Each additional pole removes more high-frequency content, simulating the attenuation of sound passing through solid material. Alien footsteps through walls use heavy multi-pole filtering at 50-120 Hz, producing a gut-level rumble that triggers an instinctive fear response without any clear sonic identification. You know something is there. You don’t know what.
Ten Ambient Soundscapes
Each of Dreadnought’s ten station sections has a unique procedurally generated ambient loop. These aren’t background music — they’re environmental signatures that establish mood and provide spatial orientation.
Reactor Core layers a heavy sub-bass throb at 30 Hz with randomized Geiger-counter crackles. Medical Bay combines dripping water clicks with eerie 1000 Hz monitor tones and a slow pad drone. Cargo Hold uses 25 Hz rumble with metallic groans and impact clanks. Science Labs generates bubbling FM synthesis between 150-220 Hz with electrical arcing crackles.
Each soundscape is a 4-second loop synthesized at startup — but because the synthesis parameters include randomization, subtle LFO modulation, and phase variation, they never sound mechanical or repetitive.
Horror Sound Design Vocabulary
Beyond ambient beds, the system includes specialized functions for psychological horror moments:
Ambush Drop (0.5s): A heavy 40 Hz thud mixed with a rising alien screech that sweeps from 400 Hz to 1000 Hz. Triggers when a creature drops from a vent above the player.
Shadow Whisper (0.8s): Heavily filtered, muffled vocal-like tones that play at the edge of audibility. Used when the player enters areas with lurking threats.
Mimic Reveal (0.6s): Wet tearing crackles mixed with organic squelch and a harmonic reveal tone. Plays when a disguised enemy reveals its true form.
Distant Scream (1.2s): A warbling human scream at 400 Hz with 200 Hz modulation depth, heavily distance-attenuated. Used to establish that you are not alone on this station.
These sounds are designed around psychoacoustic principles. Low frequencies (below 100 Hz) trigger visceral unease. Sudden frequency sweeps activate startle reflexes. Muffled, filtered sounds exploit the fear of the unknown — the brain fills in details that are scarier than anything explicit.
209 Integration Points
The audio system isn’t isolated infrastructure — it’s woven into every gameplay interaction. There are 209 audio function calls throughout Dreadnought’s codebase, covering:
- AI state transitions: Aliens produce different sounds when hunting, alerted, searching, or idle
- Environmental hazards: Acid sizzles, electrical sparks, steam bursts, each with distinct synthesis
- Player feedback: Low battery warnings, hull damage impacts, victory fanfares
- Item interactions: Keycard pickups, repair sounds, upgrade chimes
- Combat: Laser zaps, flare gun shots, stun effects with frequency warble
- UI: Computer chimes for menu selection, denial buzzes for locked actions
Every sound reinforces the game’s atmosphere while providing functional feedback. The alien chitter tells you a creature is nearby. The acid sizzle warns you about floor hazards. The keycard pickup confirms an important item was collected.
Scaling Across the Factory
Dreadnought’s 2,445-line audio engine is the most complex in the Dark Factory, but it isn’t the only one. Every game generates its own soundtrack:
| Game | Audio Lines | Functions | Focus |
|---|---|---|---|
| Dreadnought | 2,445 | 99 | Horror atmosphere, spatial audio |
| Chronostone | 310 | 14 | World-specific music loops, ability stings |
| Polybreak | 309 | 13 | Arcade music generation, power-up effects |
| Voidrunner | 186 | 13 | Drone ambience, weapon sounds |
Dreadnought is the outlier because horror as a genre depends on sound more than any other sensory channel. In a breakout game, audio is feedback. In a horror game, audio is half the experience.
The cross-game intelligence system (covered in a previous post) has already backported several audio techniques from Dreadnought to other games — master volume control from Voidrunner, drone generation patterns from Dreadnought to Voidrunner. The procedural audio patterns are part of the factory’s shared knowledge base.
What This Means
Procedural audio synthesis eliminates an entire asset category from the game development pipeline. No recording sessions. No licensing. No file management. No format conversion. No audio middleware integration. Just functions that return sample buffers.
For AI-driven development, this is a force multiplier. An agent can write, test, and iterate on a sound effect in the same cycle it writes gameplay code. There’s no context switch between “programming” and “audio production” — they’re the same activity.
The tradeoff is fidelity. Procedural waveform synthesis can’t match a professionally recorded orchestral score or a Foley artist’s library. But for indie games with a distinctive aesthetic, the constraint becomes a feature. Dreadnought’s sounds are weird, synthetic, and slightly alien — which is exactly right for a game about being trapped on a space station with hostile creatures.
2,445 lines of Lua. 99 sound effects. Zero audio files. Sometimes the best asset pipeline is no asset pipeline at all.