pychord package
- class pychord.Chord(chord: str)[source]
A chord, made up of two or more notes.
- Parameters:
chord – Name of the chord, e.g.
"C","Am7","F#m7-5/A".
- property chord: str
The name of the chord, e.g.
"C","Am7","F#m7-5/A".
- components(visible: Literal[True]) list[str][source]
- components(visible: Literal[False]) list[int]
Return the component notes of the chord.
- Parameters:
visible – Returns the note names if
True, the note pitches otherwise.
- components_with_pitch(root_pitch: int) list[str][source]
Return the component notes of chord formatted like
["C4", "E4", "G4"].- Parameters:
root_pitch – The pitch of the root note.
- classmethod from_note_index(note: int, quality: str, scale: str, diatonic: bool = False, chromatic: int = 0) Chord[source]
Create a
Chordfrom a note index in a scale.Chord.from_note_index(1, "", "Cmaj")returns I of C major => Chord(“C”)Chord.from_note_index(3, "m7", "Fmaj")returns IIImin of F major => Chord(“Am7”)Chord.from_note_index(5, "7", "Amin")returns Vmin of A minor => Chord(“E7”)Chord.from_note_index(2, "", "Cmaj")returns II of C major => Chord(“D”)Chord.from_note_index(2, "m", "Cmaj")returns IImin of C major => Chord(“Dm”)Chord.from_note_index(2, "", "Cmaj", diatonic=True)returns IImin of C major => Chord(“Dm”)Chord.from_note_index(2, "", "Cmin", chromatic=-1)returns bII of C minor => Chord(“Db”)
- Parameters:
note – Scale degree of the chord’s root,
1to7.quality – Quality of the chord, e.g.
"m7","sus4".scale – Base scale, e.g.
"Cmaj","Amin","F#maj","Ebmin".diatonic – If True, chord quality is determined using the base scale (overrides
quality).chromatic – Lower or raise the scale degree (and all notes of the chord) by semitone(s).
- property on: str
The bass note of a slash chord.
- property root: str
The root note of the chord, e.g.
"C","A","F#".
- class pychord.ChordProgression(initial_chords: str | Chord | list[str] | list[Chord] = [])[source]
A chord progression, which is a sequence of
Chordinstances.- Parameters:
initial_chords – Initial chord or chords of the chord progression.
- append(chord: str | Chord) None[source]
Append a chord to the chord progression.
- Parameters:
chord – A chord to append.
- insert(index: int, chord: str | Chord) None[source]
Insert a chord into the chord progression.
- Parameters:
index – Index to insert a chord.
chord – A chord to insert.
- class pychord.Quality(name: str, intervals: tuple[str, ...])[source]
A chord quality, defined by its intervals.
You should never need to create instances of this class yourself.
Use
QualityManagerif you need to define a new quality or override an existing one.- Parameters:
name – Name of the quality.
intervals – Intervals defining the quality.
- get_components(root: str, visible: Literal[True]) list[str][source]
- get_components(root: str, visible: Literal[False]) list[int]
- get_components(root: str, visible: bool) list[str] | list[int]
Get components of chord quality
- Parameters:
root (str) – the root note of the chord
visible (bool) – returns the name of notes if True
- Return type:
list[str|int]
- Returns:
components of chord quality
- property intervals: list[str]
The intervals definining the quality, e.g.
["1", "3", "5"]or["1", "b3", "5", "b7"].
- property quality: str
The name of the quality, e.g.
"maj","m7".