accompy.chord_resolvers

Chord resolvers — convert chord symbols to MIDI note numbers.

Registered converters: ChordSequence -> NoteSequence

Multiple backends, each wrapping a different music theory library: - pychord: lightweight, good coverage of standard chord types - music21: comprehensive, heavyweight, handles edge cases well - mingus: pure Python music theory, no C dependencies - tonal: the existing accompy dependency (thorwhalen/tonal)

Each resolver is a function: chord_symbol (str) -> list[int] (MIDI notes). We also provide converters that operate on whole ChordSequences.

accompy.chord_resolvers.chordseq_to_noteseq_mingus(cs: ChordSequence) NoteSequence

Convert ChordSequence to NoteSequence using mingus.

accompy.chord_resolvers.chordseq_to_noteseq_music21(cs: ChordSequence) NoteSequence

Convert ChordSequence to NoteSequence using music21.

accompy.chord_resolvers.chordseq_to_noteseq_pychord(cs: ChordSequence) NoteSequence

Convert ChordSequence to NoteSequence using pychord.

accompy.chord_resolvers.chordseq_to_noteseq_tonal(cs: ChordSequence) NoteSequence

Convert ChordSequence to NoteSequence using tonal.

accompy.chord_resolvers.resolve_with_mingus(symbol: str, *, root_octave: int = 3) list[int][source]

Resolve a chord symbol to MIDI notes using mingus.

>>> resolve_with_mingus("Cmaj7")
[36, 40, 43, 47]
accompy.chord_resolvers.resolve_with_music21(symbol: str, *, root_octave: int = 3) list[int][source]

Resolve a chord symbol to MIDI notes using music21.

Handles the widest range of chord types including altered chords.

>>> resolve_with_music21("Cmaj7")
[48, 52, 55, 59]
accompy.chord_resolvers.resolve_with_pychord(symbol: str, *, root_octave: int = 3) list[int][source]

Resolve a chord symbol to MIDI notes using pychord.

>>> resolve_with_pychord("Cmaj7")
[48, 52, 55, 59]
>>> resolve_with_pychord("Am")
[57, 60, 64]
accompy.chord_resolvers.resolve_with_tonal(symbol: str, *, transpose: int = -12) list[int][source]

Resolve a chord symbol to MIDI notes using the tonal package.

This is accompy’s existing default resolver.

>>> resolve_with_tonal("Cmaj7")
[48, 52, 55, 59]