pychord


Namepychord JSON
Version 1.2.2 PyPI version JSON
download
home_pagehttps://github.com/yuma-m/pychord
SummaryA library to handle musical chords in python.
upload_time2023-12-31 05:09:16
maintainer
docs_urlNone
authorYuma Mihira
requires_python>=3.6
licenseMIT
keywords music chord
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![PyChord](./pychord.png)

# PyChord ![Build Status](https://github.com/yuma-m/pychord/actions/workflows/build.yml/badge.svg) [![Documentation Status](https://readthedocs.org/projects/pychord/badge/?version=latest)](http://pychord.readthedocs.io/en/latest/?badge=latest)

## Overview

Pychord is a python library to handle musical chords.

## Installation

```sh
$ pip install pychord
```

## Basic Usage

### Create a Chord

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

### Transpose a Chord

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

### Get component notes

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

### Compare Chords

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

### Find Chords from notes

```python
>>> 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

```python
>>> 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

```python
>>> 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

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

>>> quality_manager = QualityManager()
>>> quality_manager.set_quality("11", (0, 4, 7, 10, 14, 17))
>>> Chord("C11").components()
['C', 'E', 'G', 'Bb', 'D', '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:

```python
>>> 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

- [pychord-midi.py](./examples/pychord-midi.py) - Create a MIDI file using PyChord and pretty_midi.

## Supported Python Versions

- 3.6 and above

Python 2.7 and 3.5 compatibility was dropped from version 1.0.0.

## Links

- PyPI: https://pypi.python.org/pypi/pychord
- GitHub: https://github.com/yuma-m/pychord
- Documentation: http://pychord.readthedocs.io/en/latest/

## Author

- [Yuma Mihira](https://yuma.cloud/)

## License

- MIT License

Icon is made by [Freepik](https://www.flaticon.com/authors/freepik).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/yuma-m/pychord",
    "name": "pychord",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "music chord",
    "author": "Yuma Mihira",
    "author_email": "info@yuma.cloud",
    "download_url": "https://files.pythonhosted.org/packages/cd/8b/1f0bfd3dd71f9677aae1d8cfa56c51bff8735efcf5b2c14a721685a632a2/pychord-1.2.2.tar.gz",
    "platform": null,
    "description": "![PyChord](./pychord.png)\n\n# PyChord ![Build Status](https://github.com/yuma-m/pychord/actions/workflows/build.yml/badge.svg) [![Documentation Status](https://readthedocs.org/projects/pychord/badge/?version=latest)](http://pychord.readthedocs.io/en/latest/?badge=latest)\n\n## Overview\n\nPychord is a python library to handle musical chords.\n\n## Installation\n\n```sh\n$ pip install pychord\n```\n\n## Basic Usage\n\n### Create a Chord\n\n```python\n>>> from pychord import Chord\n>>> c = Chord(\"Am7\")\n>>> c\n<Chord: Am7>\n>>> c.info()\n\"\"\"\nAm7\nroot=A\nquality=m7\nappended=[]\non=None\n\"\"\"\n```\n\n### Transpose a Chord\n\n```python\n>>> c = Chord(\"Am7/G\")\n>>> c.transpose(3)\n>>> c\n<Chord: Cm7/Bb>\n```\n\n### Get component notes\n\n```python\n>>> c = Chord(\"Am7\")\n>>> c.components()\n['A', 'C', 'E', 'G']\n>>> c.components_with_pitch(root_pitch=3)\n['A3', 'C4', 'E4', 'G4']\n```\n\n### Compare Chords\n\n```python\n>>> Chord(\"C\") == Chord(\"D\")\nFalse\n>>> Chord(\"C#\") == Chord(\"Db\")\nTrue\n>>> c = Chord(\"C\")\n>>> c.transpose(2)\n>>> c == Chord(\"D\")\nTrue\n```\n\n### Find Chords from notes\n\n```python\n>>> from pychord import find_chords_from_notes\n>>> find_chords_from_notes([\"C\", \"E\", \"G\"])\n[ <Chord: C>]\n>>> find_chords_from_notes([\"F#\", \"A\", \"C\", \"D\"])\n[ <Chord: D7/F#>]\n>>> find_chords_from_notes([\"F\", \"G\", \"C\"])\n[ <Chord: Fsus2>, <Chord: Csus4/F>]\n```\n\n### Create and handle chord progressions\n\n```python\n>>> from pychord import ChordProgression\n>>> cp = ChordProgression([\"C\", \"G/B\", \"Am\"])\n>>> cp\n<ChordProgression: C | G/B | Am>\n\n>>> cp.append(\"Em/G\")\n>>> cp\n<ChordProgression: C | G/B | Am | Em/G>\n\n>>> cp.transpose(+3)\n>>> cp\n<ChordProgression: Eb | Bb/D | Cm | Gm/Bb>\n\n>>> cp[1]\n<Chord: Bb/D>\n```\n\n## Advanced Usage\n\n### Create a Chord from note index in a scale\n\n```python\n>>> Chord.from_note_index(note=1, quality=\"\", scale=\"Cmaj\")\n<Chord: C>  # I of C major\n>>> Chord.from_note_index(note=3, quality=\"m7\", scale=\"Fmaj\")\n<Chord: Am7>  # IIIm7 of F major\n>>> Chord.from_note_index(note=5, quality=\"7\", scale=\"Amin\")\n<Chord: E7>  # V7 of A minor\n```\n\n### Overwrite the default Quality components with yours\n\n```python\n>>> from pychord import Chord, QualityManager\n>>> Chord(\"C11\").components()\n['C', 'G', 'Bb', 'D', 'F']\n\n>>> quality_manager = QualityManager()\n>>> quality_manager.set_quality(\"11\", (0, 4, 7, 10, 14, 17))\n>>> Chord(\"C11\").components()\n['C', 'E', 'G', 'Bb', 'D', 'F']\n```\n\n### Inversions\n\nChord inversions are created with a forward slash and a number\nindicating the order. This can optionally be combined with an\nadditional forward slash to change the bass note:\n\n```python\n>>> Chord(\"C/1\").components() # First inversion of C\n['E', 'G', 'C']\n>>> Chord(\"C/2\").components() # Second inversion of C\n['G', 'C', 'E']\n\n>>> Chord(\"Cm7/3/F\").components() # Third inversion of Cm7 with an added F bass\n['F', 'Bb', 'C', 'Eb', 'G']\n```\n\n## Examples\n\n- [pychord-midi.py](./examples/pychord-midi.py) - Create a MIDI file using PyChord and pretty_midi.\n\n## Supported Python Versions\n\n- 3.6 and above\n\nPython 2.7 and 3.5 compatibility was dropped from version 1.0.0.\n\n## Links\n\n- PyPI: https://pypi.python.org/pypi/pychord\n- GitHub: https://github.com/yuma-m/pychord\n- Documentation: http://pychord.readthedocs.io/en/latest/\n\n## Author\n\n- [Yuma Mihira](https://yuma.cloud/)\n\n## License\n\n- MIT License\n\nIcon is made by [Freepik](https://www.flaticon.com/authors/freepik).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A library to handle musical chords in python.",
    "version": "1.2.2",
    "project_urls": {
        "Homepage": "https://github.com/yuma-m/pychord"
    },
    "split_keywords": [
        "music",
        "chord"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a006c589ecf304d44098dd3e4a08b692bb5024818c24d37abc5c0d9421f845f4",
                "md5": "82cd114410df46cadfd93cde8a57e1d4",
                "sha256": "d111f9fcce8c150cd3b9de2b80b8f6301a3ac342c13a7ac687d74cb60320ed16"
            },
            "downloads": -1,
            "filename": "pychord-1.2.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "82cd114410df46cadfd93cde8a57e1d4",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 12697,
            "upload_time": "2023-12-31T05:09:15",
            "upload_time_iso_8601": "2023-12-31T05:09:15.209653Z",
            "url": "https://files.pythonhosted.org/packages/a0/06/c589ecf304d44098dd3e4a08b692bb5024818c24d37abc5c0d9421f845f4/pychord-1.2.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cd8b1f0bfd3dd71f9677aae1d8cfa56c51bff8735efcf5b2c14a721685a632a2",
                "md5": "1adcfe947bdd3f044dc2fa9c22817e7f",
                "sha256": "c4356030e862c1f271b89964149531ab3f2a70ea6699918e6ac93f02c5f97877"
            },
            "downloads": -1,
            "filename": "pychord-1.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1adcfe947bdd3f044dc2fa9c22817e7f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 15993,
            "upload_time": "2023-12-31T05:09:16",
            "upload_time_iso_8601": "2023-12-31T05:09:16.846893Z",
            "url": "https://files.pythonhosted.org/packages/cd/8b/1f0bfd3dd71f9677aae1d8cfa56c51bff8735efcf5b2c14a721685a632a2/pychord-1.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-31 05:09:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yuma-m",
    "github_project": "pychord",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pychord"
}
        
Elapsed time: 0.20041s