Author: | Jonathan Marmor |
---|
A simple object model for representing music notation, with a corresponding YAML format for serialization and easy editing. Generates LilyPond input files and PDFs of music notation that are highly customized for the house style of publisher Éditions musique SISYPHE (http://www.emsis.ca/publishing/composer.php?composer_id=11).
musicob/test/sample_output.pdf is an example of notation generated by MusicOb.
- notation.py is the main application and can be imported as a python library or used from the command line.
- ly2pdf.py is a standalone module for converting MusicOb-generated LilyPond files into PDF that can also be used as a library or from the command line.
- templates.py contains fragments of LilyPond input files, with huge parts hardcoded to a format that works for Éditions musique SISYPHE. There is probably a much more elegant way to do this, but this works, despite being inflexible.
A Minimal example of making a piece: one movement, one instrument, one note. Normally you would probably generate the music algorithmicly and/or type the metadata into the piece.yaml file.
>>> import os
>>> import notation
>>> here = os.path.dirname(os.path.abspath(notation.__file__))
>>> target = os.path.join(here, 'test', 'output')
>>> p = notation.Piece()
>>> p.title = 'The Star Spangled Banner'
>>> p.composer = 'John Stafford Smith'
>>> p.emsis_number = 12345 # Publisher's serial number
>>> p.filename = 'star_spangled'
>>> m = notation.Movement()
>>> p.movements = [m]
>>> m.title = 'The Only Movement'
>>> m.number = 1
>>> m.folder = 'mv1'
>>> m.tempo_duration = 4 # quarter note = 60
>>> m.tempo_bpm = 60
>>> i = notation.Instrument()
>>> m.instruments = [i]
>>> i.name = 'Clarinet'
>>> i.musician = 'Katie'
>>> i.short_name = 'cl'
>>> i.midi_name = 'clarinet'
>>> i.clef = 'treble'
>>> i.transpose_from_middle_c = "bes,"
>>> n = notation.Note()
>>> i.notation = [n]
>>> n.pitches = "<d' >"
>>> n.rehearsal_mark = 'A'
>>> n.bar = 1
>>> n.time_signature_numerator = 4
>>> n.time_signature_denominator = 4
>>> n.duration = 1
>>> n.dynamic = 'f'
Write YAML, LilyPond, PDF, and MIDI files of this little piece.
>>> paths = p.write(target, yaml=True, ly=True, pdf=True, score=True, parts=True, midi=True)
If you already have MusicOb YAML files, you can make LilyPond, PDF, and MIDI files from the command line.
$ python musicob/notation.py /path/to/yaml/files /path/for/output
If you have MusicOb LilyPond files you can make PDF and MIDI files from the command line.
$ python musicob/ly2pdf.py /path/to/lilypond/files /path/for/output piece_file_name --score --parts
To run the doctests for notation.py:
$ python musicob/notation.py musicob/test/yaml_source musicob/test/output --test
- Python 2.7 (http://python.org/)
- PyYaml (http://pyyaml.org/)
- LilyPond (http://lilypond.org/) [Currently hard coded to v2.12.3 but could easily be changed.]
- For music formatting to look right the fonts Granjon and Minion need to be installed and, if I remember correctly, registered with LilyPond in some way.
- MusicOb has only been tested on Mac OS X.
- Doesn't support tuplets of any kind.
- Doesn't support grand staves.
- Many other basic features of music haven't been implemented because I haven't needed them yet, such as temporary octave transpositions.