Package: pitchr
PitchrA python library and framework for composing music.Pitchr on PyPITargets most Linux environments.FeaturesEnables creation of music by composition of music objects (notes, chords, measures, and staffs)Unified interface for playing any music object (note.play(),staff.play())Unified interface for showing any music object (note.show(),staff.show())Spawns an image of the music objectUnified interface for exporting any music object (note.save('note.pdf'),staff.save('staff.pdf'))Flexible manipulation of musiceasily access notes by indexing a measure by beat:note0 = measure[0]edit note attributes' pitch via methodstranspose,octave_up,augmentIntelligently generates harmonies from your melodiesFinalizes your composition as beautiful standard sheet musicEnables interactive development in Jupyter NotebookInstallationTo install:pip3 install pitchr.
Other dependencies that must be installed (available via your package manager):libasound2lilypondPitchr downloads models to~/.pitchr/. Set thePITCHR_PATHenvironment variable to change this behavior.DocumentationDocumentation is hosted on Github PageshereGetting Startedfrompitchrimport*# Instantiate notesn=Note(pitch='C4',duration=1.0)# Play themn.play()# Write musicm=Measure([Note('C',1.0),Note('D',1.0),Note('E',1.0),Note('D',1.0),])# See what you've writtenm.show()# Export to PDFm.save('MySong.pdf')Helper UITo access the helper UI, run from the command line:python3 -m pitchr.helperMore Detailed NotesNote() classInit:pitch("C#6")durationin beatsdynamic(piano, forte, crescendo)articulation(staccato, accent, fermata)Note()frompitchrimport*note1=Note("C4",1,"forte")note1.mingus_note# 'C-4'note1.duration# 1note1.dynamic# "forte"note1.augment()ornote1.diminish()Chordsnote2.=Note("E4",1)chord1=Chord([note1,note2])chord1.determine()# "Major third"Measure is a collection of Notesmeasure1=Measure([note1,note2])measure1.contains(note1)# Truemeasure1.append(note3)Staff is a collection of MeasuresInit:measuresclefvoicehttps://thedpws.github.io/pitcher/staff1=music.Staff(measure1,Clef.TREBLE,Voice.PIANO)Part is a collection of Staffspart1=Part(staff1,tempo,time_signature,key_signature)part1.add_staff(staff2)part1.time_signature=3/4Score is a collection of Partsscore1=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 generationfrompitchr.harmony_makerimportbuild_harmonymy_melody=Staff(my_measures)my_harmony=build_harmony(my_melody)my_harmony.play()Running all Pitchr tests./run_pitchr_tests.shContributingSetting up dependenciespython3.8 is required for pitchr and python3 should link to python3.8 to run the testsln -s /usr/bin/python3.8 /usr/bin/python3To create the virtual environment,cdinto the project directory andpython3 -m venv envTo install dependencies to the virtual environment,source env/bin/activate && pip3 install -r requirements.txtInstall these dependencies using your local package manager (ex.sudo apt install python3-dev python3-venv libasound2 libasound2-dev lilypond):python3-devpython3-venvlibasound2libasound2-devlilypondWorking on the projectBefore working, activate the environment bysource env/bin/activateDeactivate bydeactivate