Back to browse
GitHub Repository

Music generation using the Collatz conjecture formula

4 starsC

A Collatz conjecture full music generator in 800 lines of C

by falkerdev·Apr 23, 2026·2 points·0 comments

AI Analysis

●●●●GemWizardryCozyRabbit Hole

800 lines of pure C synthesizer turns mathematical chaos into IDM — demoscene craft.

Strengths
  • Pure C with no MIDI — 11 synthesized voices, filters, and 18 glitch effects from scratch.
  • Entropy-tracking creates musical structure: calm sequences loop, chaotic jumps trigger glitches.
  • Collatz sequence drives notes, rhythm, instruments, and tempo — genuine algorithmic composition.
Weaknesses
  • Niche appeal — procedural music generators have limited practical use cases.
  • No real-time playback — generates WAV files only, not a live performance tool.
Category
Target Audience

Programmers interested in procedural generation, demoscene enthusiasts

Post Description

Hi HN, while the hype around neural networks and neural network tools is still going strong. I decided to release my project as open source it generates IDM/Ambient music based on the Collatz hypothesis using numbers. It’s a procedural synthesizer written in pure C. It takes any number, calculates a sequence for it, and uses that sequence as code to generate the source music. And yes, it’s important to note that we don’t use MIDI all sound is generated on the fly. For example, 11 synthesized voices (Additive, FM, Noise), ADSR envelopes, filters, and effects. We use the libsndfile audio library. Rather, this isn’t just random sounds the program tracks the local entropy of the sequence. If the numbers lack sharp jumps, the music loops into motifs if a sharp jump occurs, the structure breaks down, glitch effects are activated, and the tempo accelerates. This is done intentionally to try to create a composition rather than a set of notes. I wanted to explore and apply more mathematics, which is why I chose this particular approach. The code isn’t large for your convenience, I’ve implemented a variety of build methods (makefile, Docker, CMake, .bat). I’d love to hear your feedback on the synthesis architecture and ideas for other mathematical sequences that might sound interesting.

Similar Projects

Developer Tools●●●Banger

MegaHAL in Pure SQL

MegaHAL chatbot runs in pure SQL—no PL/pgSQL escape hatches, just CTEs and recursive queries.

WizardryBig BrainNiche Gem
tgies
113mo ago
Developer Tools●●Solid

A 2D animation DSL – every line written by Claude, zero human code

AI-written animation DSL with procedural bezier curves and spring physics, but output is still cartoon-level.

WizardryBold BetZero to One
siddhartha98
103mo ago