An Emacs org-babel language - provided to allow LilyPond Music Score generation, complete with optional auditioning via midi, whilst leveraging the full power of org mode, and literate programming.
There are two modes available with ob-lilypond
-
basic-mode (default)
-
arrange-mode
Which you use depends on what you intend to do.
Basic mode (the default) allows you to embed LilyPond snippets into an org mode file, and compile and export them using typical Org mode commands. This is useful if you want to mix blocks of lilypond-generated score with text, and perhaps other images, for export to latex, docbook, pdf, or html.
Following are some examples generated in ob-lilypond Basic Mode...
-
Here is an example of a pdf file containing high quality vector graphics generated by org mode and ob-lilypond.
-
and the org file that compiled the LilyPond snippets and exported the pdf.
-
Here is an example of an html page containing images (png) generated by org mode and ob-lilypond.
-
and the org file that compiled the LilyPond snippets and exported the html page.
In Basic Mode Hitting 'C-c C-c' within a lilypond block will compile the block. Exporting of all blocks and org file contents is initialted with 'C-c C-e' (standard org mode export keys).
Arrange Mode allows you to develop complete pieces of score, whilst organising sections of the piece in typical org mode ways. And because you are in Emacs org mode, you are free to use literate programming techniques to generate things programmatically / store information in tables etc. In addition, there are automated features to automatically audition the piece (via MIDI) and or display the resultant pdf output.
To change the default mode to Arrange Mode, put the following in your emacs init file...
(setq ly-arrange-mode t)
...or to temporarily switch between modes use the command M-x ly-toggle-arrange-mode
Following are examples generated using ob-lilypond in Arrange Mode...
-
Modal Cycles (Utilises org-babel and noweb to generate notes) (pdf)
-
Modal Cycles 2 (Utilises org-babel and noweb to generate notes) (pdf)
-
Modes in the Key of C (another example of polyglot lilypond programming) (pdf)
In Arrange Mode, hitting 'C-c C-c' within a lilypond block initiates ly-tangle (tangling of all lilypond blocks). Depending on the feature settings, ob-lilypond will then either display a pdf of the score, play the generated midi file, both, or neither.
M-x ly-tangle can also be called from anywhere in the file and can be tied to a function key with something like...
(global-set-key [f8] 'ly-tangle)
Some commands are included in Arrange Mode to quickly disable / enable certain post-tangle activities, including...
- ly-toggle-midi-play (toggle whether midi will be played following a successful compilation)
- ly-toggle-pdf-display (toggle whether pdf will be displayed following a successful compilation)
NOTE:- If using Timidity for midi playback, kill the midi stream with C-g in Emacs
To use ob-lilypond, you must be on a very recent version of org-mode, since it relies on a command that has been changed very recently and will break on older versions (ob-lilypond is also included in the latest org-mode by default).
For information on obtaining the latest org-mode follow this link to the Emacs Org Mode Manual and follow the instructions.
Then, add lilypond to your list of babel languages (in your init file)...
(org-babel-do-load-languages
'org-babel-load-languages
'((ruby . t)
(C . t)
(emacs-lisp . t)
(sh t)
(dot t)
(clojure t)
(ditaa t)
(lilypond t)))
To ensure all is correct consider running the tests (see below)
- LilyPond may be downloaded here
- LilyPond is available here or via the the package manager
- For MIDI, Timidity is available here or via the package manager
- For PDF, Evince is available here or via package manager
- Currently untested
Tests are provided and can be run by opening testing/lisp/test-ob-lilypond.el and running the following commands...
- M-x eval-buffer (within testing/lisp/test-ob-lilypond.el)
- M-x ert (t)
Any issues should be reported to the Emacs Org Mode Mailing-list