Git Product home page Git Product logo

musicob's Introduction

MusicOb

Author: Jonathan Marmor

Summary

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.

Usage

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

Requirements

  • 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.

Limitations

  • 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.

musicob's People

Contributors

jonathanmarmor avatar

Stargazers

David Harrison avatar Pawel Cyrta avatar  avatar Andrew Hankinson avatar

Watchers

 avatar James Cloos avatar L avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.