Skip to content

contrapunk-audio/contrapunk

Repository files navigation

Contrapunk

Contrapunk

Website · Try in Browser · Download for Mac · Contributing

Real-time counterpoint harmony generator. Plug in a guitar or MIDI controller, pick a key and voice leading style, and Contrapunk generates harmony voices that follow actual counterpoint rules -- Palestrina, Bach Chorale, Jazz, or Free. Built in Rust.

Counterpoint is the art of combining independent melodic lines. Contrapunk implements these rules so you play one note and hear harmonically correct accompaniment in real-time.

Try It

Browser (no install): app.contrapunk.com

macOS DMG: GitHub Releases

Build from Source

Prerequisites: Rust, Node.js, Tauri CLI

git clone https://github.com/contrapunk-audio/contrapunk.git
cd contrapunk
cargo tauri dev

For WASM only:

cd ui && npm install && npm run build:wasm && npm run dev

How It Works

Guitar/MIDI Input
       |
  Pitch Detection (McLeod + single-cycle, 128-sample buffer, ~2.7ms)
       |
  Harmony Engine (scales, modes, voice leading rules)
       |
  Humanizer (timing jitter, velocity variation, swing)
       |
  MIDI Output

Harmony: 8 modes (diatonic thirds, contrary motion, strict counterpoint, Barry Harris, etc.), 28 scales, 4 voice leading styles. Voice position is configurable -- play as soprano, alto, tenor, or bass.

Guitar Input: audio-to-MIDI with onset detection, pitch voting, auto-calibration, and string/fret identification. Sub-10ms pluck-to-note-on on M-series Macs.

Runs everywhere: native desktop (Tauri v2), browser (WebAssembly), same Rust core.

Examples

cargo run --release --example guitar_tuner      # Live tuner with auto-calibration
cargo run --release --example guitar_harmony    # Guitar audio -> harmony -> MIDI out
cargo run --release --example guitar_capture    # ML training data capture

Tests

cargo test                                      # Full suite
cargo test --test audio_pipeline -- --nocapture # Audio pipeline integration
cargo test -p contrapunk guitar                 # Guitar module

Pre-commit hook (fmt, clippy, test, wasm check):

cp scripts/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit

Contributing

See CONTRIBUTING.md for build setup, architecture overview, and guidelines.

Issues and PRs welcome. If you hit a bug or have a feature idea, open an issue.

Docs

License

MIT. See LICENSE.

About

Music improvisation and performance companion

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors