#Rust

Contrapunk: Real-Time Counterpoint Engine That Turns Guitar into Harmony

Startups Reporter
2 min read

Contrapunk is a browser-based MIDI harmony generator and guitar-to-MIDI converter that applies centuries of counterpoint rules in real-time with sub-10ms latency.

Contrapunk is a browser-based MIDI harmony generator and guitar-to-MIDI converter that applies centuries of counterpoint rules in real-time with sub-10ms latency.

The Problem: Harmony Generation Without the Theory

Musicians have long struggled with two fundamental challenges: generating harmonically rich accompaniments in real-time and converting guitar performances into MIDI data without expensive hardware. Traditional harmony generators often produce parallel fifths and octaves that violate classical rules, while guitar-to-MIDI conversion typically requires specialized pickups or suffers from latency that makes live performance impossible.

The Solution: Centuries of Music Theory in Rust

Contrapunk solves these problems by implementing proper counterpoint rules directly in code. The system features 8 harmony modes including Palestrina, Bach, Jazz, and Free, each applying specific voice-leading rules that have governed Western music for centuries. The engine handles 28 scale modes and maintains deterministic voicing to ensure consistent results.

The guitar input system uses real-time pitch detection with onset tracking and auto-calibration, allowing any electric guitar to function as a MIDI controller without additional hardware. This democratizes access to sophisticated harmony generation that was previously limited to keyboard players or those with expensive MIDI setups.

Technical Architecture: Sub-10ms Latency

Built entirely in Rust, Contrapunk achieves sub-10ms latency through single-cycle detection, 2-frame voting, and 128-sample buffers. The core engine runs everywhere - native desktop via Tauri, browser via WebAssembly, and server mode for studio integration - all sharing the same Rust codebase.

Voice leading is handled with parallel fifths rejection, voice crossing prevention, and proper spacing rules. The system maintains up to 4 voices simultaneously while ensuring each voice moves independently according to the selected counterpoint style.

Accessibility and Open Source

Contrapunk is free with no login required, and the browser version works in Chrome with any MIDI controller. The MIT license ensures that centuries of music theory remain accessible to every musician. The project represents a unique intersection of classical music theory, real-time audio processing, and modern web technologies.

Try Contrapunk in your browser or download for Mac to experience real-time counterpoint generation that respects the rules that have shaped Western music for centuries.

Comments

Loading comments...