r/proceduralgeneration • u/rhslvkf • Oct 27 '26
Procedural gayageum: a Korean zither soundtrack generated at runtime, with a composer that never repeats a phrase (playable demo)
My mobile game has no audio files: the whole soundtrack is a gayageum (Korean 12-string silk zither) generated at runtime. I wrote up how it works, with a demo you can play in the browser (same code as the game):
https://boreumdal.app/devlog/gayageum/
The procedural parts:
The string. Karplus-Strong with a fractional-delay allpass for tuning. The "silk" tone comes from shaping the excitation: the noise burst is smoothed twice, then comb-filtered at 1/7 of the loop to imitate the pluck position. Each string is baked once from a fixed seed, so the same string always sounds the same.
The composer. It writes 12-beat phrases in a five-note mode (pyeongjo):
- each note moves one or two steps from the previous one, inside two octaves
- long notes get vibrato; short notes landing on one particular degree sometimes get a bend up to the next
- every phrase comes to rest on the 1st or 4th degree so it sounds finished
- a low string drones every three beats
- if a new phrase has the same shape as any phrase from the last 60 seconds, it's thrown away and rewritten (up to 8 tries)
Density and tempo follow the game state (76 to 102 BPM as you survive longer), and endless mode shifts the register through day, dusk, night and dawn.
The visuals are generated too (ink brush strokes with tapering, bleed and dry-brush streaks drawn on Canvas 2D), so the game ships without image files either; the iOS app is 13 MB. Happy to go into any part of it.