Skip to main content

Pitchr

A python library and framework for composing music. Pitchr on PyPI

Targets most Linux environments.

Features

  1. Enables creation of music by composition of music objects (notes, chords, measures, and staffs)
  2. Unified interface for playing any music object (note.play(), staff.play())
  3. Unified interface for showing any music object (note.show(), staff.show())
  • Spawns an image of the music object
  1. Unified interface for exporting any music object (note.save('note.pdf'), staff.save('staff.pdf'))
  2. Flexible manipulation of music
  • easily access notes by indexing a measure by beat: note0 = measure[0]
  • edit note attributes' pitch via methods transpose, octave_up, augment
  1. Intelligently generates harmonies from your melodies
  2. Finalizes your composition as beautiful standard sheet music
  3. Enables interactive development in Jupyter Notebook

Installation

To install: pip3 install pitchr. Other dependencies that must be installed (available via your package manager):

  • libasound2
  • lilypond

Pitchr downloads models to ~/.pitchr/. Set the PITCHR_PATH environment variable to change this behavior.

Documentation

Documentation is hosted on Github Pages here

Getting Started

from pitchr import *

# Instantiate notes
n = Note(pitch='C4', duration=1.0)

# Play them
n.play()

# Write music

m = Measure([
    Note('C', 1.0),
    Note('D', 1.0),
    Note('E', 1.0),
    Note('D', 1.0),
])

# See what you've written
m.show()

# Export to PDF
m.save('MySong.pdf')

Helper UI

To access the helper UI, run from the command line: python3 -m pitchr.helper

helper_ui

More Detailed Notes

flow

Note() class

Init:

  • pitch ("C#6")
  • duration in beats
  • dynamic (piano, forte, crescendo)
  • articulation (staccato, accent, fermata)

Note()

from pitchr import *
note1 = Note("C4", 1, "forte")
note1.mingus_note # 'C-4'
note1.duration # 1
note1.dynamic # "forte"
note1.augment() or note1.diminish()

Chords

note2. = Note("E4", 1)
chord1 = Chord([note1, note2])
chord1.determine() # "Major third"

Measure is a collection of Notes

measure1 = Measure([note1, note2])
measure1.contains(note1) # True
measure1.append(note3)

Staff is a collection of Measures

Init:

staff1 = music.Staff(measure1, Clef.TREBLE, Voice.PIANO)

Part is a collection of Staffs

part1 = Part(staff1, tempo, time_signature, key_signature)
part1.add_staff(staff2)
part1.time_signature = 3/4

Score is a collection of Parts

score1 = Score("My Song", "Wonderful Subtitle", "Author Me", "me@email.com")
score1.get_author() # "Author Me"
score1.get_title() # "My Song"
score1.add_part(part1)

Harmony generation

from pitchr.harmony_maker import build_harmony
my_melody = Staff(my_measures)
my_harmony = build_harmony(my_melody)

my_harmony.play()

Running all Pitchr tests

./run_pitchr_tests.sh

Contributing

Setting up dependencies

  • python3.8 is required for pitchr and python3 should link to python3.8 to run the tests
  • ln -s /usr/bin/python3.8 /usr/bin/python3
  • To create the virtual environment, cd into the project directory and python3 -m venv env
  • To install dependencies to the virtual environment, source env/bin/activate && pip3 install -r requirements.txt
  • Install these dependencies using your local package manager (ex. sudo apt install python3-dev python3-venv libasound2 libasound2-dev lilypond):
    • python3-dev
    • python3-venv
    • libasound2
    • libasound2-dev
    • lilypond

Working on the project

  • Before working, activate the environment by source env/bin/activate
  • Deactivate by deactivate

Metadata

Release files for pitchr 1.1.0

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

Source distribution (sdist)

Source distribution for pitchr 1.1.0
File Size Uploaded Provenance Actions
pitchr-1.1.0.tar.gz 30.6 kB Without provenance Details for pitchr-1.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 79.8 kB

Release files / pitchr-1.1.0.tar.gz

Download URL pitchr-1.1.0.tar.gz
Size 30.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fa10faf1b2c26bd7cfd99d994365f393baf839150f7a713d6018d3a96e483c82
BLAKE2b-256 checksum
How to use checksums
f6cf27b4e827185260b6e9201c969259e472b35af18cdad7b8b15aaec9716821
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2

Release files / pitchr-1.1.0-py3-none-any.whl

Download URL pitchr-1.1.0-py3-none-any.whl
Size 49.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e9aaa5be0c3c08260232d67b0bd5f64dff9c77159b5cc7c0349747d7074a5b91
BLAKE2b-256 checksum
How to use checksums
25179d821e8b966da0188e2cc35012044f4fe190fa2f2a6cd51c73eb01563d26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2

Security for pitchr 1.1.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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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