Reflect a chord across the tonic–dominant axis of a key (negative harmony).
Every pitch class p maps to (2*T + 7 - p) mod 12, where T is the key
tonic — the reflection that swaps the tonic with the dominant. The mirrored
pitch classes (including the bass, if set) are reassembled into a chord by
detectChordBest; when no chord is recognized, the mirrored root and
the original quality are used as a fallback.
The result is spelled the way key writes it, as rootSpelling and
bassSpelling hints, so the reflection of a chord in a flat-side key keeps
flat names: in Eb major the mirror of Bb formats as Abm, not G#m.
import { negativeHarmonyMirror, makeChord, majorKey } from'@libraz/libcantus'; negativeHarmonyMirror(makeChord(7, 'maj'), majorKey(0)); // G major reflected across C's axis => F minor (rootPc 5, quality 'min')
Reflect a chord across the tonic–dominant axis of a key (negative harmony).
Every pitch class
pmaps to(2*T + 7 - p) mod 12, whereTis the key tonic — the reflection that swaps the tonic with the dominant. The mirrored pitch classes (including the bass, if set) are reassembled into a chord by detectChordBest; when no chord is recognized, the mirrored root and the original quality are used as a fallback.The result is spelled the way
keywrites it, asrootSpellingandbassSpellinghints, so the reflection of a chord in a flat-side key keeps flat names: in Eb major the mirror of Bb formats asAbm, notG#m.