let harmony = Engine.new(Palestrina);
fn detect_pitch(buf) -> Note
const MAX_VOICES: usize = 4;
voice_leading.reject_parallels()
struct GuitarInput { onset }
engine.harmonize(note, scale)
fn detect_pitch(
  buf: &[f32]
) -> Option<Note>
let voices =
  counterpoint::
    generate(line, mode);
if interval == Fifth
  && motion == Parallel
  { reject() }
#[inline(always)]
fn onset(
  frame: &Frame
) -> bool
block_size: 128
sample_rate: 48_000
latency_ms: 7.2
// Palestrina
// counterpoint
// rules.rs
CONTRAPUNK WEEKEND JAM·WK 01·Koji Kondo· STARTS IN 2DAYS→ /jam
TUTORIAL · 5 MINUTES

GETTING STARTED.

Up and running in under 5 minutes. Pick an input, follow 4 steps, hear counterpoint.

◆ ◇ ◆ ◇ ◆ CHOOSE YOUR INPUT

Contrapunk turns notes into harmony. Pick how you want to send notes in:

◆ ◇ ◆ ◇ ◆ BROWSER · QUICKEST START
STEP 01

Open app.contrapunk.com in Chrome or Edge (Web MIDI requires Chromium).

STEP 02

Select an input device from the dropdown. If you have a MIDI controller plugged in, it will appear here.

STEP 03

Select an output device. To hear sound, you need a software synth receiving MIDI. On macOS, set up an IAC Driver to route MIDI to your DAW or synth app.

STEP 04

Press Start. Play a note. Hear harmony.

◆ ◇ ◆ ◇ ◆ MIDI KEYBOARD
WHAT YOU NEED
  • A USB MIDI controller (any keyboard, pad controller, or wind controller)
  • A software synth or DAW to receive the harmonized MIDI output
STEP 01 · OPEN THE APP

Go to app.contrapunk.com in Chrome or Edge.

LOWER LATENCY

For the lowest latency, (Apple Silicon · ~18 MB).

STEP 02 · CONNECT

Plug in your MIDI controller. It should appear in the Input dropdown. Select it.

For output, select your synth's MIDI port, or use an IAC Driver to route to a DAW.

STEP 03 · CONFIGURE

Pick your settings:

  • Key + Scale: set the musical key (e.g. C Major, D Dorian)
  • Harmony Mode: choose how harmony is generated (Diatonic Thirds, Contrary Motion, Strict Counterpoint, etc.)
  • Voice Leading: Palestrina, Bach, Jazz, or Free
STEP 04 · PLAY

Press Start. Every note you play generates harmony voices in real-time following the counterpoint rules you selected.

◆ ◇ ◆ ◇ ◆ GUITAR INPUT
WHAT YOU NEED
  • An electric guitar (or acoustic with pickup)
  • An audio interface (e.g. Focusrite Scarlett, Audient iD14, etc.)
  • A software synth or DAW to receive MIDI output
STEP 01 · CONNECT

Plug your guitar into your audio interface. (native recommended for lowest latency).

STEP 02 · SELECT DEVICE

In the Guitar Input panel, select your audio interface from the device dropdown. Choose the correct channel (usually 1 for mono guitar).

STEP 03 · CALIBRATE

Click Tune + Calibrate. Tune each string when prompted. Contrapunk learns your guitar's response: gain levels, noise floor, and string characteristics.

TIP

Calibration only takes 30 seconds and dramatically improves detection accuracy. Do it once per guitar.

STEP 04 · CHECK SIGNAL

Strum your guitar. The signal meter should respond. If it looks flat, check:

  • Correct channel selected
  • Audio interface gain is up
  • Guitar volume knob is up
STEP 05 · PLAY

Set your key, scale, and harmony mode. Press Start. Play single notes or melodies. Contrapunk detects each note and generates harmony in real-time.

TIP

For best results, play clean single notes. Chords and heavy distortion make pitch detection harder. Clean tone works best.

◆ ◇ ◆ ◇ ◆ IAC DRIVER · macOS

IAC (Inter-Application Communication) is a virtual MIDI bus built into macOS. It lets Contrapunk send MIDI to any app: Logic, Ableton, GarageBand, a standalone synth, etc.

STEP 01 · OPEN AUDIO MIDI SETUP

Open Audio MIDI Setup (search in Spotlight or find in /Applications/Utilities).

If you don't see the MIDI Studio window, go to Window > Show MIDI Studio.

STEP 02 · ENABLE IAC DRIVER

Double-click IAC Driver in the MIDI Studio window.

Check Device is online.

You should see at least one port listed (usually "Bus 1"). That's all you need.

STEP 03 · USE IN CONTRAPUNK

Back in Contrapunk, the IAC Driver port will now appear in the Output dropdown. Select it.

STEP 04 · RECEIVE IN YOUR DAW

In your DAW or synth app:

  • Logic Pro: create a Software Instrument track. MIDI from IAC is received automatically.
  • Ableton Live: Preferences > MIDI > enable IAC Driver as input (Track + Remote).
  • GarageBand: create a Software Instrument track. IAC MIDI appears automatically.
NOTE

IAC is macOS only. On Windows, use loopMIDI for virtual MIDI routing. On Linux, JACK or ALSA virtual ports work similarly.

◆ ◇ ◆ ◇ ◆ WHAT NEXT
  • Try different harmony modes: Strict Counterpoint follows Renaissance rules, Barry Harris uses jazz 6th diminished movement
  • Experiment with voice leading styles: Palestrina rejects parallel fifths, Jazz allows them
  • Enable modal interchange to harmonize out-of-scale notes by borrowing from parallel modes
  • Try the style presets for instant character changes
  • Adjust humanization for timing jitter, velocity variation, and swing