Initial release: procedural techno music generator

Synthesizes kick, snare, hi-hat, bass, and acid lead from scratch.
32-bar song structure with filter sweeps and pattern variation.
Outputs raw float32 stereo at 44.1 kHz to stdout.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-21 08:47:22 +00:00
commit d58d0d3b09
3 changed files with 509 additions and 0 deletions

69
README.md Normal file
View File

@@ -0,0 +1,69 @@
# techno-gen
Generates infinite procedural techno music as raw float32 stereo audio on stdout.
138 BPM. No samples — everything is synthesized from scratch.
## Build
```sh
make
```
Or manually:
```sh
gcc -O2 -Wall -lm -o techno-gen techno-gen.c
```
## Play
Pipe directly into `paplay` (PulseAudio):
```sh
./techno-gen | paplay --format=float32le --rate=44100 --channels=2
```
> **Note:** `paplay` is part of the `pulseaudio-utils` package.
> On Debian/Ubuntu: `sudo apt install pulseaudio-utils`
### Mono version (if you only want 1 channel)
The program outputs stereo (2 channels). If you want mono, mix down with sox:
```sh
./techno-gen | sox -t raw -r 44100 -e float -b 32 -c 2 - -t raw -r 44100 -e float -b 32 -c 1 - | paplay --format=float32le --rate=44100 --channels=1
```
### Record to file
```sh
./techno-gen | sox -t raw -r 44100 -e float -b 32 -c 2 - output.wav trim 0 120
```
This records 2 minutes (`trim 0 120`) to `output.wav`.
## What it sounds like
| Time | Section |
|---------------|----------------------------------------------------|
| 03 bars | **Intro** — kick + bass, filter closed |
| 47 bars | **Rise** — hi-hats join, filter opens |
| 815 bars | **Full** — snare, acid lead, LFO filter sweeps |
| 1619 bars | **Breakdown** — bass only, stripped down |
| 2023 bars | **Build** — kick returns, filter climbs |
| 2431 bars | **Heavy** — syncopated kick, acid variation 2 |
| *then loops* | Back to bar 8 (never the sparse intro again) |
The cycle is 32 bars (~1 min 23 sec at 138 BPM), then repeats with continuous filter and pattern variation.
## Synthesis
All audio is synthesized in real time:
- **Kick** — sine oscillator with pitch envelope (200 → 45 Hz), amp decay, transient click
- **Snare** — high-pass filtered noise blended with a 185 Hz tone
- **Hi-hat** — noise through a 7 kHz high-pass; open/closed variants with different decay times
- **Bass** — sawtooth oscillator through a resonant (Q=4.5) biquad low-pass with per-note filter envelope and glide
- **Acid lead** — dual slightly-detuned sawtooth through a very resonant (Q=6) low-pass; filter sweeps with LFO per section
- **Stereo width** — short delay line (~11 ms) ping-ponged between channels on hats and acid
- **Master** — `tanh` soft saturation to keep levels honest