1 #+OPTIONS: H:3 num:nil toc:2 \n:nil @:t ::t |:t ^:{} -:t f:t *:t TeX:t LaTeX:t skip:nil d:(HIDE) tags:not-in-toc
2 #+STARTUP: align fold nodlcheck hidestars oddeven lognotestate hideblocks
3 #+SEQ_TODO: TODO(t) INPROGRESS(i) WAITING(w@) | DONE(d) CANCELED(c@)
4 #+TAGS: Write(w) Update(u) Fix(f) Check(c) noexport(n)
5 #+TITLE: Org-babel-lilypond
8 #+STYLE: <style type="text/css">#outline-container-introduction{ clear:both; }</style>
11 <div id="subtitle" style="float: center; text-align: center;">
14 <a href="http://lilypond.org/">Lilypond (Score Engraving and Arrangement)</a>
17 <a href="http://lilypond.org/">
18 <img src="../examples/lilypond-examples/basic-mode/html-example/mixolydian.png">
26 An /Emacs Org Babel language/ - provided to allow [[http://lilypond.org][LilyPond]] Music Score generation, complete
27 with optional auditioning via Midi, whilst leveraging the full power of Org mode, and [[http://en.wikipedia.org/wiki/Literate_programming][Literate Programming]].
31 There are two modes available with ob-lilypond
33 - *basic-mode* (default)
37 Which you use depends on what you intend to do.
38 (A quick way to switch modes is via `*M-x ly-toggle-arrange-mode*').
40 *basic-mode* (the default) allows you to embed LilyPond snippets into an org mode file, and
41 compile and export them using typical Org mode commands (such as *C-c
42 C-e d* for pdf export). This is useful if you want to mix
43 blocks of Lilypond-generated score with text, and perhaps other images for export to Latex,
44 Docbook, pdf, or HTML. In other words, *basic-mode* could be used as a
45 very flexible replacement to *lilypond-book*.
47 *Warning!* in *basic-mode* a Lilypond source block requires to be passed
48 a *:file* parameter as shown below, as failure to do so will result
51 : #+begin_src lilypond :file Mixolydian.png
54 : g a b c d e f g f e d c b a g a b c d e f g f e d c b a g1
57 The previous block will produce an image file in .png format, which
58 would be suitable for exporting to HTML for instance. See
59 [[file:../examples/lilypond-examples/html-example.org][html-example.org]] for a more complete example.
61 To generate a nice image for embedding into a pdf or Latex document,
62 you might consider using the .eps format as shown in the example
65 : #+begin_src lilypond :file Mixolydian.eps
68 : g a b c d e f g f e d c b a g a b c d e f g f e d c b a g1
71 See [[file:../examples/lilypond-examples/pdf-example.org][pdf-example.org]] for a more complete example.
75 Following are some examples generated in ob-lilypond Basic Mode...
77 - [[file:../examples/lilypond-examples/html-example.org][and the org file]] that compiled the LilyPond snippets and exported
78 the HTML page (using the sequence *C-c C-e b*).
80 * Compiling LilyPond Blocks
81 In *basic-mode* the key sequence *C-c C-c* within a Lilypond block
82 will compile the block. Exporting of all blocks and org file contents
83 is initialted with the sequence *C-c C-e* (standard org mode export keys).
86 *arrange-mode* allows you to develop complete pieces of score, whilst
87 organising sections of the piece using typical Org-mode techniques. And because
88 you are in Org-mode, you are free to use Literate Programming
89 techniques to generate things programatically - store information in
92 In addition, there are automated features to automatically audition
93 the piece (via MIDI) and or display the resultant pdf output.
95 To change the default mode to Arrange Mode, put the following in your emacs init file:
97 : (setq ly-arrange-mode t)
99 ...or to temporarily switch between modes use the following command:
101 : *M-x ly-toggle-arrange-mode*
103 Following are examples generated using ob-lilypond in Arrange Mode...
105 - [[file:../examples/lilypond-examples/modal-cycles.pdf][Modal Cycles (Utilises org-babel and noweb to generate notes)]] (pdf)
106 - [[file:../examples/lilypond-examples/modal-cycle.midi][Generated Midi File]]
107 - [[file:../examples/lilypond-examples/modal-cycle.org][Source Org File]]
109 - [[file:../examples/lilypond-examples/modal-cycle-2.pdf][Modal Cycles 2 (Utilises org-babel and noweb to generate notes)]] (pdf)
110 - [[file:../examples/lilypond-examples/modal-cycle-2.midi][Generated Midi File]]
111 - [[file:../examples/lilypond-examples/modal-cycle-2.org][Source Org File]]
112 - [[file:../examples/lilypond-examples/arrange-mode/Modal-Cycle-2.mp3][A sound file produced with minor tinkering of the sounds triggered by the Lilypond-generated MIDI]]
113 - [[file:../examples/lilypond-examples/modes-in-key-of-c.pdf][Modes in the Key of C (another example of polyglot lilypond
115 - [[file:../examples/lilypond-examples/modes-in-key-of-c.midi][Generated Midi File]]
116 - [[file:../examples/lilypond-examples/modes-in-key-of-c.org][Source Org File]]
118 * Tangling and Compiling LilyPond Blocks
119 In *arrange-mode*, the key sequence *C-c C-c* within a Lilypond block
120 initiates `ly-tangle' (tangling of all Lilypond blocks within the
121 current Org file). Depending on the feature settings, ob-lilypond will
122 then either /display a pdf/ of the score, /play the generated MIDI
123 file/, both, or neither.
125 The command *M-x ly-tangle* can also be called from anywhere in the file
126 and could be tied to a function key with something like...
128 : (global-set-key [f8] 'ly-tangle)
130 Some commands are included in arrange-mode to quickly enable / disable certain post-tangle
131 activities, including:
133 - *ly-toggle-midi-play* (toggle whether midi will be played following a successful compilation)
134 - *ly-toggle-pdf-display* (toggle whether pdf will be displayed following a successful compilation)
136 *NOTE:-* If using [[http://timidity.sourceforge.net/][Timidity]] for MIDI playback, kill the MIDI stream with C-g in Emacs
139 To use *ob-lilypond*, you must be on a *very recent* version of
140 org-mode, (since it relies on a command that has been changed very
141 recently) and will break on older versions (ob-lilypond is also
142 included in the latest Org-mode by default).
144 For information on obtaining the latest org-mode follow this link
145 to the [[http://orgmode.org/manual/Installation.html][Org-mode Manual]] and follow the instructions.
147 Then, add lilypond to your list of babel languages (in your init
150 : (org-babel-do-load-languages
151 : 'org-babel-load-languages
158 Alternatively you may *require* the ob-lilypond babel language directly:
160 : (require 'lilypond)
162 To ensure all is correct consider *running the tests* (see below).
167 - LilyPond may be [[http://lilypond.org/][downloaded here]]
170 - LilyPond is [[http://lilypond.org/][available here]] or via the the system-relevant package manager.
171 - For MIDI, *Timidity* is [[http://timidity.sourceforge.net/][available here]] or via the system-relevant package manager.
172 - For pdf, *Evince* is [[http://live.gnome.org/Evince/Downloads][available here]] or via package manager.
175 - Currently untested, although it should be made to work with minimal fuss.
178 Tests are provided and can be executed by running the following commands...
179 (for more help and information on testing see [[file:../../../org-tests/index.html][Testing Org]].
181 : M-x load-file RET testing/lisp/test-ob-lilypond.el
185 Any issues should be reported to the [[http://orgmode.org][Org-mode Mailing-list]]