The chord symbol text.
Optionalopts: NoteNameOptions
system reads the root and bass in that notation system instead
of English.
The parsed chord.
If the root or quality is not recognized in that system. Use tryParseChordSymbol where failure is ordinary, such as a chord field read on every keystroke.
import { parseChordSymbol, formatChordSymbol } from '@libraz/libcantus';
const c = parseChordSymbol('Bbmaj7');
formatChordSymbol(c); // 'Bbmaj7' — flat spelling is preserved on round-trip
parseChordSymbol('H7', { system: 'german' }).rootPc; // 11 — the B natural
parseChordSymbol('B', { system: 'german' }).rootPc; // 10 — the German B flat
Parse a lead-sheet chord symbol into a Chord.
Accepts
<root><quality>[/<bass>], e.g.Cmaj7,F#m7b5,Bb7,C/G,C6/9,C6/9/E. Root and bass letters are case-insensitive, matching parseNote. A/is ambiguous between a slash bass and the6/9quality; the text splits at the last/whose right-hand side is a valid bare note preceded by a recognized quality, so6/9(with or without a further slash bass) parses as a quality.The root and bass are read in
system, so a German chart'sH7,As7andGes/Bare read by asking for'german'. The system is never inferred: with none given the symbol is English, whereBis the B natural andHno note at all. Case carries nothing in a chord symbol — unlike a German key name, where the case of the tonic is the mode — so the quality suffix alone says major or minor. Where a German root's flat suffix could equally open the quality, the longest root that leaves a known quality behind wins:Asus4is an A suspended chord andAssus4the A flat one.The quality suffix is read structurally when no name covers it, so a chart's bracketed tensions parse as readily as the names do:
Cmaj7(#11),C7(b9,#11),C7(13),Csus4(add9),C-Δ9,C6/9(#11). A/between two figures separates them as it does inside brackets, which is what the sixth and ninth of a6/9are. Such a chord carries the tones it names and reports the nearest quality name (see chordSpecQuality); read chordSpecOf for its structure.The parsed chord carries the root/bass spellings as enharmonic hints (
rootSpelling/bassSpelling) so formatChordSymbol can reproduce flat spellings such asBbmaj7instead of respelling them with sharps.