pychord package
Subpackages
Submodules
pychord.analyzer module
- pychord.analyzer.find_chords_from_notes(notes: List[str]) List[Chord][source]
Find possible chords consisted from notes
- Parameters:
notes – List of note arranged from lower note. ex) [“C”, “Eb”, “G”]
- Returns:
List of chord
pychord.chord module
- class pychord.chord.Chord(chord: str)[source]
Bases:
objectClass to handle a chord.
- Attributes:
_chord: Name of the chord. (e.g. C, Am7, F#m7-5/A) _root: The root note of chord. (e.g. C, A, F#) _quality: The quality of chord. (e.g. maj, m7, m7-5) _appended: The appended notes on chord. _on: The base note of slash chord.
- property appended
The appended notes on chord
- property chord
The name of chord
- components(visible: bool = True) List[str] | List[int][source]
Return the component notes of chord
- Parameters:
visible – returns the name of notes if True else list of int
- Returns:
component notes of chord
- 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
- Returns:
component notes of chord
- classmethod from_note_index(note: int, quality: str, scale: str, diatonic: bool = False, chromatic: int = 0) Chord[source]
Create a Chord from 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 (1-7)
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 :param quality)
chromatic – Lower or raise the scale degree (and all notes of the chord) by semitone(s)
- property on
The base note of slash chord
- property quality
The quality of chord
- property root
The root note of chord
pychord.parser module
pychord.progression module
- class pychord.progression.ChordProgression(initial_chords: str | Chord | List[str | Chord] = [])[source]
Bases:
objectClass to handle chord progressions.
- Attributes:
_chords: component chords of chord progression.
- append(chord: str | Chord) None[source]
Append a chord to chord progressions
- Parameters:
chord – A chord to append
- insert(index: int, chord: str | Chord) None[source]
Insert a chord to chord progressions
- Parameters:
index – Index to insert a chord
chord – A chord to insert
pychord.quality module
- class pychord.quality.Quality(name: str, components: Tuple[int, ...])[source]
Bases:
objectChord quality
- append_on_chord(on_chord, root)[source]
Append on chord
To create Am7/G q = Quality(‘m7’) q.append_on_chord(‘G’, root=’A’)
- Parameters:
on_chord (str) – bass note of the chord
root (str) – root note of the chord
- get_components(root='C', visible=False)[source]
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 quality
Get name of quality
pychord.utils module
- pychord.utils.note_to_val(note: str) int[source]
Get index value of a note
>>> note_to_val("C") 0 >>> note_to_val("B") 11