-
Notifications
You must be signed in to change notification settings - Fork 0
Procedural Audio
There are no sound files in this game. Not one .wav, not one .mp3. Every
chime, every bass note, the whole 30-second soundtrack — it's all synthesized in
real time while you play, and it stays musical no matter how chaotic the physics get.
Here's how, in plain terms.
Digital sound is just a list of numbers describing a wave — for CD-quality audio,
44,100 numbers per second. Normally those numbers come from a recording. Here, the
game calculates them on the fly and hands them to the speakers, batch by batch,
using Godot's AudioStreamGenerator and its push_frame() method.
math ──► 44,100 samples/sec ──push_frame──► AudioStreamGenerator ──► your ears
(a sine wave
at a pitch)
It's like drawing the sound wave by hand, fast enough that it never runs out. That means the game can make any note at any moment in response to what just happened in the physics — something pre-recorded clips can't do.
If every cube collision played a random pitch, it would sound like someone falling down stairs onto a piano. The fix is one idea borrowed from music theory:
Everything melodic uses a single scale — C minor pentatonic.
A pentatonic scale is the "no wrong notes" scale (it's why mashing the black keys on a piano sounds vaguely pleasant). So when a cube smacks a ramp, the game doesn't play the physically "correct" frequency — it snaps that pitch to the nearest note in the scale. Every impact therefore belongs to the same key as the background music, and the random clatter of physics harmonizes into a tune instead of fighting it.
The bass riff, the end-of-round urgency sweep, and the collision chimes are all in that one key, so they can never clash.
When you start a round, a looping bass-and-drum bed plays — roughly one beat per second — so you can feel the 30-second timer ticking without staring at a number. As the clock runs down, the final seconds speed up and rise in pitch: an audible "hurry up." It's information delivered as music.
You can literally see the design: the evenly spaced vertical columns are the ~1-beat-per-second clock; the discrete bands near the bottom are notes snapped to the scale (not a continuous smear); the tall spikes reaching ~16 kHz are collision chimes with their harmonics.
In main_v2.gd, search for the banner PROCEDURAL AUDIO and the
Musical scale (C minor pentatonic) block. A few knobs to play with:
| Constant | Meaning | Try |
|---|---|---|
SAMPLE_RATE (44100) |
samples generated per second | leave it |
GLOBAL_AUDIO_RATE_HZ (9.0) |
how often the synth refills its buffer | raise for snappier impact sound |
| the scale table | the actual notes | swap C-minor-pentatonic for another scale to re-color the whole game's mood |
Why this is worth studying: procedural audio is a superpower on a constrained device. Zero asset size, infinite variation, and it's reactive — the soundtrack is literally a function of the gameplay. If you've only ever played back audio clips, this is a fun rabbit hole.
Next: visionOS Gotchas → the silent failures to know about before you lose a day to them.
Built by Alex Coulombe (@ibrews) · Source · Independent project — not affiliated with or endorsed by the Godot Foundation; "Godot" is a trademark of the Godot Foundation.
Developer Guide (ELI5)
- 1 · Getting Started
- 2 · How the Game Is Built
- 3 · Hand Tracking
- 4 · Procedural Audio
- 5 · visionOS Gotchas
- 6 · Build & Deploy
Links