
Composed, not played back
Most chord tools in a DAW are libraries: you pick a progression and it loops. CONTRAPUNKT works the other way round. Nothing is stored as a fixed loop. Every progression is written by the engine from the rules you give it, and every change of chord is voiced so that each part moves as little as it can.
The progression isn’t played back. It’s composed — chord by chord, voice by voice.
8
chords in every progression
12
candidates tried for each choice; the smoothest voice leading wins
2
voices: Bass on Ch 1, Barbieri Seq on Ch 2
0
semitone clashes with the bass in a 123,000-note test
You set the rules, the engine writes the chords
You start with a root, a mode and an archetype. The modes run from Dorian to Phrygian and Locrian. Archetypes such as Gondwana or Baroque Lament give the progression its character. Modal motion decides how the mode itself is allowed to move.
Three knobs then steer the writing. Gravity pulls the progression toward the tonic. Modality sets how strongly the mode colours the chords. Tension leans the harmony toward the cadence. The knobs don’t pick chords directly. They change the odds the engine works with, and the engine still chooses the voicing that moves least.
The engine writes eight chords. For each choice it tries 12 candidates and keeps the one with the smoothest voice leading, using inversions, slash basses and 4–3 suspensions where they help. Changes always land on the next chord boundary, never in the middle of a chord, so you can turn knobs freely during a set without breaking the phrase. Tap a chord to loop it; tap several to loop a passage.

Each voice moves to the nearest note
Voice leading is the oldest idea in counterpoint, and the one the plugin is named after. When the harmony changes, each upper voice should travel to the nearest available note of the new chord instead of jumping. For every new chord CONTRAPUNKT compares candidate voicings and keeps the one where the four upper voices cover the shortest total distance. The result sounds like parts being sung, not chords being stamped.

Two voices from one harmony
VOICE · 01
Bass · MIDI Ch 1
Holds the root, or the slash bass when the chord asks for one, and takes a passing note just before a change.
VOICE · 02
Barbieri Seq · MIDI Ch 2
Arpeggiates the chord’s voices in phrases of 4 to 16 steps. Both voices read the same progression, so they always agree on the harmony.
Each voice has the same six controls, so the bass and the sequence can be shaped separately: Density, Tactility, Spread, Tone, Dynamics and Level. CONTRAPUNKT can play its own built-in synth or send MIDI to Ableton, to loopMIDI or to any other port.

A phrase isn’t a bar
The sequence does not think in bars. Its phrase length is set by Phase Steps, from 4 to 16 steps. When the phrase length divides the bar, the two line up. When it doesn’t, the arpeggio slides across the bar line and starts on a different step each time round. With a phrase of 6 steps in a 16-step bar, phrase and bar only meet again after 48 steps, three bars later. The same chords keep sounding new.

The wrong-note guard
A semitone between an upper voice and the bass is the most common wrong note in generated harmony, and early loops of the plugin had a few of them. CONTRAPUNKT now checks every note against the bass before it plays. In a test of 123,000 notes across every preset and all 12 modes, it produced no semitone clashes with the bass.
- Flat nine. Kept only where the chord names it (C7b9), and more than an octave above the bass.
- Laments. The ninth is checked against a third in the bass, as in Fm9/Ab.
- Ringing notes. No note rings on into the next chord.
- Legato. No semitone overlaps between tied notes.

In the rig
One switch, SYNC: HOST, hands tempo and transport to the host: press play in Ableton and CONTRAPUNKT plays with it. MIDI ports are remembered by name rather than by number, so the rig survives a reboot or a re-plugged interface, and a port that disappears for a moment is found again within one or two seconds. One routing tip saves a lot of confusion: a track set to “All Ins” also hears loopMIDI and doubles every note, so pick the port by name.

MIDI Learn starts from the MIDI button. Almost everything can be learned: the six instrument parameters, Gravity, Modality, Tension, Swing, Phase Steps, Transpose, Root, Mode, Archetype, Modal Motion, synth and effects, Play, the Theme and Seq buttons and each track’s on/off switch. The map is saved in a single file, midi_learn.json, shared by every project, so a controller set up once works everywhere. Inside the host, knobs arrive through VST3 MIDI mapping: 128 controller numbers map to hidden parameters, so learning works even when the host owns the MIDI input.

Under the hood
CONTRAPUNKT is native C++ on the Steinberg VST3 SDK, with a web interface inside the plugin window. The work is split into three layers. The audio thread plays the notes and never waits on a lock, so timing stays tight. A worker applies automation within about 10 ms, recomposes and reconnects ports. The window only shows what is happening and never holds up the sound.
Every build runs a host test before it is used: 132 engine combinations, transport, sound and notes on both channels, a save-and-reload of the state, and MIDI Learn.

Whatever belongs to a song travels with the Ableton set: knobs and settings, the progression and its loops, MIDI ports by name, channels and host sync. Whatever belongs to you and your controller is stored once on the computer: the MIDI Learn map and the theme. Any edit marks the set as changed, so Ableton asks to save before closing.

CONTRAPUNKT pairs with HALFSTEPER, the rhythm generator: one writes the harmony, the other the drums, and both follow Ableton’s clock.
Technical notes: stack, algorithms, code
This part is for developers. The excerpts below are copied from the CONTRAPUNKT source and from the test harness used to check it. Lines and fragments marked … are omissions or short editorial notes; all other comments are the original ones.
STACK
What it is built with
| Language | C++17 |
|---|---|
| Plugin API | Steinberg VST3 SDK: IEditController, IMidiMapping, IConnectionPoint, IComponentHandler2 |
| Engine | HarmonyEngine (progressions and voicing), SequencerEngine (bass and Barbieri Seq), TransportEngine, MidiLearnEngine |
| Interface | An HTML/JS view inside the plugin window; messages to and from C++ as JSON (nlohmann/json) |
| Threads | Audio thread (lock-free atomics only), worker thread, UI thread |
| Musical scope | 12 modes, 11 harmonic archetypes, 6 kinds of modal motion, 14 presets |
| Platform | Windows, VST3 (Contrapunkt.vst3), built with build.ps1 |
ENGINE · 01
The harmony API
Everything starts from one MacroParams structure: root, mode, archetype, modal motion, seed and the knob values. HarmonyEngine::generateProgression() returns the chords as VoiceChord objects. Each one carries five voices, where voices[0] is the bass and the other four are the upper parts, along with its pitch classes, bass and root, symbol, key context, suspension data and its position in beats. SequencerEngine then renders the two layers into note events: layer 0 is the bass and layer 1 is the sequence. The twelve modes are natural minor, harmonic minor, melodic minor, Dorian, Phrygian, Phrygian dominant, Lydian, Lydian dominant, Mixolydian, Locrian, major and double harmonic.
MacroParams p = preset(0);
p.archetype = (HarmonicArchetype)a;
p.mode = (ScaleMode)mo;
p.modalMotion = (ModalMotion)mm;
p.seed = 1000 + s * 77;
p.root = 2;
HarmonyEngine h;
auto ch = h.generateProgression(p, nullptr);
for (auto& c : ch) {
auto [r, m] = ctx(c.keyContext);
auto sc = HarmonyEngine::getScaleIntervals(m);
// … every chord PC must belong to its own key context
}ENGINE · 02
The wrong-note guard
Before the sequencer commits a note, it checks it against the bass of the current chord. A note a semitone above the bass pitch class (a flat ninth or minor second) is rejected unless the chord explicitly asks for a flat nine and the note sits more than an octave above. Version 10 added the mirror case: a note a semitone below the bass, as with the ninth of Fm9/Ab, is rejected unless the chord is a root-position major seventh. A suspension that would clash is resolved at once instead of being held.
auto isFalseNote = [&](int p, bool isSuspNote) {
if (mod12(p - chordBassMidi) == 1 &&
!(chordWantsFlatNine(*c) && p - chordBassMidi >= 13)) {
return true;
}
// v10: a voice a semitone BELOW the bass pitch class (e.g. the 9th of Fm9/Ab: G against Ab)
// rubs as a major 7th / minor 2nd against the bass. Only a root-position maj7 chord keeps it.
if (mod12(chordBassMidi - p) == 1 &&
!/* … root-position maj7 exception … */) {
return true;
}
// …
};
// …
if (inSusp && suspHeld && isFalseNote(midiPitch, true)) {
// A suspension that would sound as b9/b2 against the bass resolves immediately instead.
// …
}REAL TIME · 03
Nothing slow on the audio thread
The audio thread must never wait. When the host sends parameter changes, the plugin only stores them in atomics and raises a flag. Recomposing a progression, which can take longer than one audio buffer, happens on the worker thread, which notices the flag within about 10 ms. Even the tempo is read from a cached atomic rather than through the transport’s lock.
// …
shared->midiLearn.pushFromAudio(static_cast<int>(pid - kCCParamBase),
static_cast<int>(std::lround(val * 127.0)));
} else if (pid < kNumVstParams) {
double prev = shared->vstParams[pid].load(std::memory_order_relaxed);
if (std::fabs(val - prev) > 0.002) {
shared->vstParams[pid].store(val, std::memory_order_relaxed);
anyChange = true;
}
}
// …
// v10: never regenerate on the audio thread; the worker applies it within ~10 ms.
if (anyChange) shared->automationDirty.store(true, std::memory_order_release);
// …
double hostBpm = shared->cachedBpm.load(std::memory_order_relaxed); // v10: no lock on the audio threadMIDI · 04
MIDI Learn through IMidiMapping
A VST3 plugin usually does not see the raw MIDI CC messages, because the host keeps them. Through IMidiMapping the plugin asks the host to deliver every controller number as a hidden parameter, kCCParamBase + cc. These 128 parameters are not automatable and exist only to carry CC values. On the audio thread a value is written into an atomic slot, and a 128-bit dirty mask marks it. The worker drains the mask, binds a CC while learning and applies bound CCs to the engine.
// --- IMidiMapping: every incoming CC (any channel) becomes hidden parameter kCCParamBase + cc ---
tresult PLUGIN_API getMidiControllerAssignment(int32 busIndex, int16 /*channel*/,
CtrlNumber midiControllerNumber, ParamID& id) SMTG_OVERRIDE {
if (busIndex != 0 || midiControllerNumber < 0 || midiControllerNumber >= kNumCCParams) return kResultFalse;
id = kCCParamBase + static_cast<ParamID>(midiControllerNumber);
return kResultTrue;
}
// …
int32 PLUGIN_API getParameterCount() SMTG_OVERRIDE { return kNumVstParams + kNumCCParams; }
tresult PLUGIN_API getParameterInfo(int32 index, ParameterInfo& info) SMTG_OVERRIDE {
if (index >= kNumVstParams && index < kNumVstParams + kNumCCParams) {
std::memset(&info, 0, sizeof(info));
int cc = index - kNumVstParams;
info.id = kCCParamBase + static_cast<ParamID>(cc);
info.unitId = kRootUnitId;
info.flags = 0; // like JUCE's MIDI CC parameters: not automatable, only fed by IMidiMapping
// …// ---- AUDIO THREAD (lock-free, no allocation) ----
void pushFromAudio(int cc, int value) noexcept {
if (cc < 0 || cc >= kNumCC) return;
ccVal_[static_cast<size_t>(cc)].store(std::clamp(value, 0, 127), std::memory_order_relaxed);
dirty_[cc >> 6].fetch_or(1ULL << (cc & 63), std::memory_order_release);
}
// ---- UI / worker side ----
static bool isKnownTarget(const std::string& t) {
static const char* kTargets[] = {
"gravity", "modality", "tensionArc", "swing", "transpose", "bpm", "phaseLength",
"root", "mode", "archetype", "modalMotion",
"internalSynthLevel", "synthWarmth", "delayMix", "reverbMix",
"L0.density", "L0.tactility", "L0.spread", "L0.tone", "L0.dynamics", "L0.level", "L0.mute",
"L1.density", "L1.tactility", "L1.spread", "L1.tone", "L1.dynamics", "L1.level", "L1.mute",
"play", "mutate", "mutateHarmony", "mutateSequence", "synthToggle"};
for (const char* k : kTargets) if (t == k) return true;
return false;
}HOST · 05
Saving with the set
For Ableton to ask about saving, the plugin has to say that the project changed. It does so through IComponentHandler2::setDirty() after every message from the interface that changes state. Messages that change nothing worth saving are excluded, such as refreshing the port list, a test note, play/stop and theme changes.
void markDirty() {
if (!compHandler) return;
FUnknownPtr<IComponentHandler2> h2(compHandler);
if (h2) h2->setDirty(true);
}
// …
static const char* kNoSaveTypes[] = {"ready", "refreshMidi", "testMidiNote", "saveMidiDialog",
"togglePlay", "setTheme", "midiLearnArm", "midiLearnCancel",
"midiLearnClear", "midiLearnClearAll"};
bool savable = true;
for (const char* t : kNoSaveTypes) {
if (type == t) { savable = false; break; }
}
if (savable) controller->markDirty();TEST · 06
How the 123,000-note check works
The guard was measured with a separate harness that links the engine directly, without a host. It renders every one of the 14 presets in all 12 modes with three seeds. For each composition it also renders loops of selected chords, then compares every pair of overlapping bass and sequence notes. Semitones and flat ninths are counted by type, and the explicit 7b9 colour is reported separately as allowed.
int main() {
SequencerEngine eng;
for (int pr = 0; pr < 14; ++pr) for (int mo = 0; mo < 12; ++mo) for (int s = 0; s < 3; ++s) {
MacroParams p = preset(pr); p.mode = (ScaleMode)mo; p.seed += s * 331;
auto comp = eng.generate(p); analyze(comp, p);
for (int k = 0; k < (int)comp.chords.size(); k += 3) {
MacroParams m2 = p; m2.selectedChords = {k};
auto c2 = comp; eng.renderLayers(c2, m2); analyze(c2, m2);
}
}
// … print counts per clash type
}The deck
All 13 slides of “CONTRAPUNKT — how it works”. Click a slide to enlarge it; use the arrow keys to move through the deck.
01Cover — CONTRAPUNKT
02What it is
03The principle
04You set the rules. The engine writes the chords.
05Each voice moves to the nearest note
06Two voices from one harmony
07A phrase isn’t a bar
08No notes that rub against the bass
09Follows the host, finds its ports
10Any control, on any controller
11Native C++, three layers
12What it remembers
13Turn a knob. Hear what the harmony says.Facts, concepts & context
- HALFSTEPER[plugin]Zemla Studio’s rhythm generator; writes the drums while CONTRAPUNKT writes the harmony.
- voice leading[concept]Moving each voice to the nearest note of the next chord. The engine keeps the smoothest of 12 candidates.
- modes[concept]Dorian, Phrygian, Locrian and the rest: 12 modes, all covered by the wrong-note test.
- VST3[technology]Steinberg’s plugin format. CONTRAPUNKT is native C++ on the VST3 SDK.
- loopMIDI[tool]Virtual MIDI ports on Windows; one of the destinations for the two voices.
- Zemla Studio[studio]Experimental design studio from Lviv: art, science and technology, put to work on a story.
- Gravity [instrument / technology]instrument / technology. UA · Centrum Mundi — CXIII — Ukrainian Music Engineering: Oleksii Hrachov…
- Windows [instrument / technology]instrument / technology. T.A.M. Club / Centrum Mundi corpus · HALFSTEPER: a drum generator where the kick holds and everything else…
- Ableton Live [instrument / technology]instrument / technology. T.A.M. Club / Centrum Mundi corpus · Centrum Mundi — LX — Anton Lapov: Media Art, the Luhansk Underground…
- Zemla Studio [label / press]label / press. T.A.M. Club / Centrum Mundi corpus · The Lecture That Wasn’t Supposed to Happen: RASTER // ATLAS, Paradoxes…
- Gondwana [label / press]label / press. T.A.M. Club / Centrum Mundi corpus · Centrum Mundi — N031 — Tomasz Bednarczyk (New Rome): From Room40 and…
- DAW [instrument / technology]instrument / technology. T.A.M. Club / Centrum Mundi corpus · HALFSTEPER: a drum generator where the kick holds and everything else…
- slide [instrument / technology]instrument / technology. T.A.M. Club / Centrum Mundi corpus · HALFSTEPER: a drum generator where the kick holds and everything else…
