musthe
Music theory implemented in Python. Notes, scales and chords.
It is still in development so feel free to read the code, fork and make pull requests! They are very welcome!
Installation
To install:
$ pip install musthe
Development install
To install as development:
(Optional) Create a virtualenv:
$ python -m venv env
$ source env/bin/activate
Then install:
$ pip install -e .
How to use
It is very simple, everything is coded in a object-oriented style, for example:
$ python
>>> from musthe import *
>>> a = Note('A') #Default A4
>>> a
Note("A4")
>>> str(a)
'A'
Suppose you want to create tension, so you want the perfect fifth or the minor seventh of that A, so you do:
>>> fifth = Interval('P5')
>>> seventh = Interval('m7')
>>> a+fifth
Note("E5")
>>> str(a+fifth)
'E'
>>> str(a+seventh)
'G'
Though it is important to see that the octaves of those notes are different:
>>> a.octave
4
>>> (a+seventh).octave
5
Now let's see basic chord usage:
>>> Chord(Note('A'), 'M')
Chord(Note('A'), 'M')
>>> Chord(Note('A'), 'M').notes
[Note("A4"), Note("C#5"), Note("E5")]
>>> Chord(Note('Bb'), 'dim').notes
[Note("Bb4"), Note("Db5"), Note("Fb5")]
You can use a string to construct a chord:
>>> Chord('C#aug7') == Chord(Note('C#'), 'aug7')
True
Default chord type is 'M' (Major).
Now lets try scales:
>>> s = Scale(Note('B'), 'major')
>>> [s[i] for i in range(len(s))]
[Note('B4'), Note('C#5'), Note('D#5'), Note('E5'), Note('F#5'), Note('G#5'), Note('A#5')]
>>> s[0]
Note('B4')
>>> s[-11]
Note('E3')
It return a list of Note instances, so if you want a cleaner result should do something like:
>>> s = Scale(Note('B'), 'major')
>>> [str(s[i]) for i in range(len(s))]
['B', 'C#', 'D#', 'E', 'F#', 'G#', 'A#']
To check if notes and chords are contained in a given scale:
>>> Note('D#3') in s
True
>>> Note('F3') in s
False
>>> Chord('C#m') in s
True
>>> Chord('CM') in s
False
Now let's try some advanced stuff: given a list of chords, find all scales that contain those:
>>> chords = [Chord('Cm'), Chord('Fm7'), Chord('Gm')]
>>> for scale in Scale.all():
... if chords in scale:
... print(scale)
...
C natural_minor
Eb major
If you have lilypond installed, you can make little melodies using this program, an example is given in 'lilypond_example.py'
Contributors
In alphabetical order
- David H
- Edgar Gavrik
- Federico Ferri
- Gonzalo Ciruelos
- Marco Heins
- nvoster
- Sri Raghavan
- Sylvain
- zsinx6
License
See license file.
Metadata
Release files for musthe 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| musthe-1.0.0.tar.gz | 8.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| musthe-1.0.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 14.8 kB
Release files / musthe-1.0.0.tar.gz
| Download URL | musthe-1.0.0.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
46825a7fcbf638e2617277c2ddfceac658e09fab9746e2bff17c9a548278f6ee
|
|
BLAKE2b-256 checksum How to use checksums |
961736aefdc50455aa5528431f75c98a36f114595626cb91d71ee4ad53285b8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / musthe-1.0.0-py2.py3-none-any.whl
| Download URL | musthe-1.0.0-py2.py3-none-any.whl |
|---|---|
| Size | 6.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f1439a86e46ee37bc05202ec489df2815071a7b0afce19f3808dd34441f64c57
|
|
BLAKE2b-256 checksum How to use checksums |
fbcc82660a8755a43b916114e2a86e83931066745db79b63b6dff5448ae07901
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for musthe 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.