Toolbox for analyzing, creating and visualizing music
Project description
musy
Installation
pip install musy
How to use
Note
from musy import Note, Chord, Scale
The Note is
the basic building block from which you can create chords and songs.
c_sharp = Note("C#")
c_sharp
musy.core.Note(note='C#', oct=4)
Notes can be added and subtracted to form new notes. Each added integer represents a semitone.
c_sharp + 1
musy.core.Note(note='D', oct=4)
c_sharp - 1
musy.core.Note(note='C', oct=4)
c_sharp + 14
musy.core.Note(note='D#', oct=5)
Intervals can be obtained by comparing a note with a different note or string.
c_sharp.interval("F#")
'perfect fourth'
Shorthand is also available for intervals.
c_sharp.interval("B", short=True)
'b7'
Notes can be converted to its relative major or minor.
Note("C").minor()
musy.core.Note(note='A', oct=4)
Note("C#").major()
musy.core.Note(note='E', oct=4)
Chord
The Chord is
a collection of
Note objects
played together.
c_major = Chord(["C", "E", "G"])
c_major
Chord: 'C major triad'. Notes: ['C4', 'E4', 'G4']
Chord objects
can be initialized from shorthand notation.
cmaj7 = Chord.from_short("Cmaj7")
cmaj7
Chord: 'C major seventh'. Notes: ['C4', 'E4', 'G4', 'B4']
Chords can also be inverted with invert.
cmaj7.invert(1)
Chord: 'C major seventh, first inversion'. Notes: ['E4', 'G4', 'B4', 'C5']
Like Note
objects,
Chord objects
can be added and subtracted to transpose them.
cmaj7 + 2
Chord: 'D major seventh'. Notes: ['D4', 'F#4', 'A4', 'C#5']
Notes can be multiplied to create chords.
Note("C") * Note("E") * Note("G")
Chord: 'C major triad'. Notes: ['C4', 'E4', 'G4']
For advanced usage there is even a way to create
PolyChord
objects, which have much of the same functionality as
Chord objects
and more.
Chord.from_short("C") % Chord.from_short("Bbmaj7").invert(3)
PolyChord: 'C major triad|Bb major seventh, third inversion'. Notes: ['C4', 'E4', 'G4', 'A4', 'Bb5', 'D5', 'F5']
Scale
Scale objects
are collections of intervals from which we can generate notes and chords
around a root note.
dorian = Scale("dorian")
dorian
Dorian. ['1', '2', 'b3', '4', '5', '6', 'b7']
When given a root note,
Scale
generates the notes of the scale.
dorian.get_notes("C")
[musy.core.Note(note='C', oct=4),
musy.core.Note(note='D', oct=4),
musy.core.Note(note='Eb', oct=4),
musy.core.Note(note='F', oct=4),
musy.core.Note(note='G', oct=4),
musy.core.Note(note='A', oct=4),
musy.core.Note(note='Bb', oct=4)]
Intervals can be obtained.
dorian.get_interval_names()
['unison',
'major second',
'minor third',
'perfect fourth',
'perfect fifth',
'major sixth',
'minor seventh']
Triads and seventh chords in the scale can be generated around a root note.
dorian.get_triads("D")
[Chord: 'D minor triad'. Notes: ['D4', 'F4', 'A4'],
Chord: 'E minor triad'. Notes: ['E4', 'G4', 'B4'],
Chord: 'F major triad'. Notes: ['F4', 'A4', 'C4'],
Chord: 'G major triad'. Notes: ['G4', 'B4', 'D5'],
Chord: 'A minor triad'. Notes: ['A4', 'C4', 'E5'],
Chord: 'B diminished triad'. Notes: ['B4', 'D5', 'F5'],
Chord: 'C major triad'. Notes: ['C5', 'E6', 'G6']]
dorian.get_sevenths("E")
[Chord: 'E minor seventh'. Notes: ['E4', 'G4', 'B4', 'D4'],
Chord: 'F# minor seventh'. Notes: ['F#4', 'A4', 'C#4', 'E5'],
Chord: 'G major seventh'. Notes: ['G4', 'B4', 'D4', 'F#5'],
Chord: 'A dominant seventh'. Notes: ['A4', 'C#4', 'E5', 'G5'],
Chord: 'B minor seventh'. Notes: ['B4', 'D4', 'F#5', 'A5'],
Chord: 'C# half diminished seventh'. Notes: ['C#5', 'E6', 'G6', 'B6'],
Chord: 'D major seventh'. Notes: ['D5', 'F#6', 'A6', 'C#6']]
Consult
Scale.available_scales
for a list of available scales. If a scale is not available, you can
create your own scale from intervals.
persian = Scale.from_intervals("persian", ["1", "b2", "3", "4", "b5", "b6", "7"])
persian
Persian. ['1', 'b2', '3', '4', 'b5', 'b6', '7']
persian.get_notes("C")
[musy.core.Note(note='C', oct=4),
musy.core.Note(note='Db', oct=4),
musy.core.Note(note='E', oct=4),
musy.core.Note(note='F', oct=4),
musy.core.Note(note='F#', oct=4),
musy.core.Note(note='Ab', oct=4),
musy.core.Note(note='B', oct=4)]
Note,
Chord,
PolyChord
and Scale
objects can all be heard by calling the play method on them.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file musy-0.0.3.tar.gz.
File metadata
- Download URL: musy-0.0.3.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e2b9a8b4f377adaf0e57b3e09317f9453e4997dfc760c3199d99f5dd80b7e23
|
|
| MD5 |
a426dc6735d3f6da7500d8347d2f241f
|
|
| BLAKE2b-256 |
48f8ee22fc7c882769ebf6406e944c7b8dff80e7f556436a65739273b1a3f353
|
File details
Details for the file musy-0.0.3-py3-none-any.whl.
File metadata
- Download URL: musy-0.0.3-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
007e383ff23258e34389db0459d9a60fe62f0035b8bb0bf38952df9e15b8d960
|
|
| MD5 |
afa48ff840590e8af2a6867c70584046
|
|
| BLAKE2b-256 |
a7c83e0da5fbc805a93b6790c62027bf3b54a07f72b03fe7586b17cd44cd0d8c
|