pychord package


pychord.analyzer module

pychord.analyzer.find_chords_from_notes(notes: List[str]) → List[pychord.chord.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.analyzer.get_all_rotated_notes(notes: List[str]) → List[List[str]][source]

Get all rotated notes

get_all_rotated_notes([A,C,E]) -> [[A,C,E],[C,E,A],[E,A,C]]

pychord.analyzer.notes_to_positions(notes: List[str], root: str) → List[int][source]

Get notes positions from the root note

>>> notes_to_positions(["C", "E", "G"], "C")
[0, 4, 7]
  • notes – List of notes
  • root – Root note

List of note positions

pychord.chord module

class pychord.chord.Chord(chord: str)[source]

Bases: object

Class to handle a chord.

_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.

The appended notes on chord


The name of chord

components(visible: bool = True) → Union[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) → pychord.chord.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”)

  • 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)

Return information of chord to display


The base note of slash chord


The quality of chord


The root note of chord

transpose(trans: int, scale: str = 'C') → None[source]

Transpose the chord

  • trans – Transpose key
  • scale – key scale

pychord.parser module

pychord.parser.parse(chord: str) → Tuple[str, pychord.quality.Quality, List[str], str][source]

Parse a string to get chord component

Parameters:chord – str expression of a chord
Returns:(root, quality, appended, on)

pychord.progression module

class pychord.progression.ChordProgression(initial_chords: Union[str, pychord.chord.Chord, List[Union[str, pychord.chord.Chord]]] = [])[source]

Bases: object

Class to handle chord progressions.

_chords: component chords of chord progression.
append(chord: Union[str, pychord.chord.Chord]) → None[source]

Append a chord to chord progressions

Parameters:chord – A chord to append

Get component chords of chord progression

insert(index: int, chord: Union[str, pychord.chord.Chord]) → None[source]

Insert a chord to chord progressions

  • index – Index to insert a chord
  • chord – A chord to insert
pop(index: int = -1) → pychord.chord.Chord[source]

Pop a chord from chord progressions

Parameters:index – Index of the chord to pop (default: -1)
transpose(trans: int) → None[source]

Transpose whole chord progressions

Parameters:trans – Transpose key

pychord.quality module

class pychord.quality.Quality(name: str, components: Tuple[int, ...])[source]

Bases: object

Chord 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’)

  • 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

  • root (str) – the root note of the chord
  • visible (bool) – returns the name of notes if True
Return type:



components of chord quality


Get name of quality

class pychord.quality.QualityManager[source]

Bases: object

Singleton class to manage the qualities

find_quality_from_components(components: List[int])[source]

Find a quality from components

Parameters:components – components of quality
get_quality(name: str, inversion: int = 0) → pychord.quality.Quality[source]
set_quality(name: str, components: Tuple[int, ...])[source]

Set a Quality

This method will not affect any existing Chord instances. :param name: name of quality :param components: components of quality

pychord.utils module

pychord.utils.display_appended(appended: List[str]) → str[source]
pychord.utils.display_on(on_note: str) → str[source]
pychord.utils.note_to_val(note: str) → int[source]

Get index value of a note

>>> note_to_val("C")
>>> note_to_val("B")
pychord.utils.transpose_note(note: str, transpose: int, scale: str = 'C') → str[source]

Transpose a note

>>> transpose_note("C", 1)
>>> transpose_note("D", 4, "A")
pychord.utils.val_to_note(val: int, scale: str = 'C') → str[source]

Return note by index in a scale

>>> val_to_note(0)
>>> val_to_note(11, "D")

Module contents