Skip to main content

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']

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

musy-0.0.2.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

musy-0.0.2-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file musy-0.0.2.tar.gz.

File metadata

  • Download URL: musy-0.0.2.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for musy-0.0.2.tar.gz
Algorithm Hash digest
SHA256 e88e39b51109cd691900712f8a35e979d2e51bd1e4b302989f4e47d39d630d6b
MD5 9ef25a23df2d51ce60e925014fc35be6
BLAKE2b-256 609a920ad77a280b4bb4feb536b0073f21405a8d756f7e1ded67fb99058f6376

See more details on using hashes here.

File details

Details for the file musy-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: musy-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.0

File hashes

Hashes for musy-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0c870f46f3666733811e822067d0f38ad348e2d7867ca718e20dae34ee415e0c
MD5 d135f6aaeddc3dca686d2b49bc6e5d66
BLAKE2b-256 e536d6fa752faa3c84beeea87acac5e54c5e855abc07780ea5dd27159f784bbb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page