Contrapunk: Real-Time Counterpoint Harmony Engine Built in Rust Achieves Sub-10ms Latency
Contrapunk — Where Music Theory Meets Modern Engineering
A new open-source project called Contrapunk has launched, offering a real-time MIDI harmony generator that applies centuries-old counterpoint rules with sub-10ms latency. Built entirely in Rust, it runs everywhere from browsers to native desktops.
What It Does
Contrapunk provides:
- 8 harmony modes — Palestrina, Bach, Jazz, and Free modes, each implementing authentic counterpoint rules
- 28 scale modes — Comprehensive musical scale support
- Guitar-to-MIDI conversion — Real-time pitch detection and onset tracking for guitarists
- Voice leading enforcement — Parallel fifths rejection, voice crossing prevention, spacing rules
- Sub-10ms latency — Single-cycle detection, 2-frame voting, 128-sample buffers
Technical Architecture
The project uses a single Rust core that compiles to multiple targets:
| Target | Technology | Use Case |
|---|---|---|
| Browser | WebAssembly | Online music creation |
| Desktop | Tauri | Native performance |
| Server | Rust binary | Studio environments |
The Philosophy
"AI is not going to kill music till people keep playing music together. So let's jam!" — The Contrapunk team emphasizes human musical expression over AI-generated content.
Why Counterpoint Matters
Counterpoint rules, developed over centuries from Palestrina to Bach, represent some of humanity's most refined musical knowledge. Encoding these rules in software makes them accessible to every musician, regardless of their formal music education.
Open Source
Released under the MIT license, Contrapunk is completely free. The team's philosophy: "Counterpoint rules are centuries of human knowledge. They should be accessible to every musician."
Source: contrapunk.com, Hacker News