Skip to main content

PyChord

PyChord Build Status Documentation Status

Overview

PyChord is a Python library to handle musical chords.

Installation

PyChord supports Python 3.10 and above.

$ pip install pychord

Basic Usage

Create a Chord

>>> from pychord import Chord
>>> c = Chord("Am7")
>>> c
<Chord: Am7>
>>> c.info()
"""
Am7
root=A
quality=m7
on=None
"""

Transpose a Chord

>>> c = Chord("Am7/G")
>>> c.transpose(3)
>>> c
<Chord: Cm7/Bb>

Get component notes

>>> c = Chord("Am7")
>>> c.components()
['A', 'C', 'E', 'G']
>>> c.components_with_pitch(root_pitch=3)
['A3', 'C4', 'E4', 'G4']

Compare Chords

>>> Chord("C") == Chord("D")
False
>>> Chord("C#") == Chord("Db")
True
>>> c = Chord("C")
>>> c.transpose(2)
>>> c == Chord("D")
True

Find Chords from notes

>>> from pychord import find_chords_from_notes
>>> find_chords_from_notes(["C", "E", "G"])
[ <Chord: C>]
>>> find_chords_from_notes(["F#", "A", "C", "D"])
[ <Chord: D7/F#>]
>>> find_chords_from_notes(["F", "G", "C"])
[ <Chord: Fsus2>, <Chord: Csus4/F>]

Create and handle chord progressions

>>> from pychord import ChordProgression
>>> cp = ChordProgression(["C", "G/B", "Am"])
>>> cp
<ChordProgression: C | G/B | Am>

>>> cp.append("Em/G")
>>> cp
<ChordProgression: C | G/B | Am | Em/G>

>>> cp.transpose(+3)
>>> cp
<ChordProgression: Eb | Bb/D | Cm | Gm/Bb>

>>> cp[1]
<Chord: Bb/D>

Advanced Usage

Create a Chord from note index in a scale

>>> Chord.from_note_index(note=1, quality="", scale="Cmaj")
<Chord: C>  # I of C major
>>> Chord.from_note_index(note=3, quality="m7", scale="Fmaj")
<Chord: Am7>  # IIIm7 of F major
>>> Chord.from_note_index(note=5, quality="7", scale="Amin")
<Chord: E7>  # V7 of A minor

Overwrite the default Quality components with yours

>>> from pychord import Chord, QualityManager
>>> Chord("C11").components()
['C', 'E', 'G', 'Bb', 'D', 'F']

>>> quality_manager = QualityManager()
>>> quality_manager.set_quality("11", ("1", "3", "5", "b7", "11"))
>>> Chord("C11").components()
['C', 'E', 'G', 'Bb', 'F']

Inversions

Chord inversions are created with a forward slash and a number indicating the order. This can optionally be combined with an additional forward slash to change the bass note:

>>> Chord("C/1").components() # First inversion of C
['E', 'G', 'C']
>>> Chord("C/2").components() # Second inversion of C
['G', 'C', 'E']

>>> Chord("Cm7/3/F").components() # Third inversion of Cm7 with an added F bass
['F', 'Bb', 'C', 'Eb', 'G']

Examples

Author

License

  • MIT License

The logo is made from Freepik.

Metadata

Release files for pychord 1.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pychord 1.4.1
File Size Uploaded
pychord-1.4.1.tar.gz 19.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pychord 1.4.1
File Interpreter ABI Platform
pychord-1.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 33.6 kB

Release files / pychord-1.4.1.tar.gz

Download URL pychord-1.4.1.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b5fd9f5722b4a612e7ac6ab2e5d497e36220962523009cfd22b8190f22ce8314
BLAKE2b-256 checksum
How to use checksums
50f104db07eff6fc9cea6b6e919dc9df50d7022e80ae805b344b7e673dbe7ba4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / pychord-1.4.1-py3-none-any.whl

Download URL pychord-1.4.1-py3-none-any.whl
Size 14.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b19e64c142ef2735e8d9cd6459fc15307690eaf2aeb143ae23d901e2753694ac
BLAKE2b-256 checksum
How to use checksums
4cb787d34da61c50fa11000bc999df9ddcfa61e21bcbddbda7c191f90153186e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release history Release notifications | RSS feed

This release

1.4.1 This release

2 release files

1.4.0

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

2 release files

0.2.9

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.5

2 release files

0.2.4

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page