Lilytool is a Python environment for processing the Lilypond music
notation language.

Author: John Galbraith <john@maxwellsdemon.com>

Lilytool offers three main components.
1) Parser
2) Generator
3) "Pythonic" API

The parser reads lilypond source code and creates a Pythonic syntax
tree, suitable for arbitrary manipulations in Python.  The generator
produces lilypond source code from the (manipulated) syntax tree.  You
can manipulate each notation in your score using the Python API.

* motivation *

Lilypond is a phenominal tool.  The output is beautiful, the software
implementation is mature, and the input language is excels for large,
complex musical situations.  The language itself, however, is perhaps
under exploited for a wider variety of applications.  As far as I
know, it is the only serious way to capture complex musical notations
in an open (free as in speech), well designed format.

On the other hand, programming Lilypond in a text editor is not always
the most efficient way to generate, process, or filter your notation.
There are GUI entry tools available, but they stumble on complex
scores.  Furthermore, sometimes what you need is a lilypond "filter",
useable in classic UNIX command line pipeline, which basically
transforms one lilypond file into another more to your liking.
Lilypond itself offers scriptability using the Scheme language, which
is used extensively internally by the lilypond typsetter.
Unfortunately, not many people know Scheme and in my personal opinion,
Python can do everything that Scheme can do at least as well and is
usually much easier to read and write.  So I want to manipulate
Lilypond using Python, not Scheme.

Personally, I created this tool to process the Lilypond export from
the Rosegarden sequencer.  Rosegarden is another great tool, that
compliments Lilypond nicely.  Rosegarden has a Lilypond export that
works.  However, the formatting details do not suit the needs of my
progressive rock band, Maxwell's Demon.  Our scores are basically
large orchestral works with lots of interwoven parts, and processing
the raw Rosegarden export looks yucky.  Initially, I used a Python
hack to fix some small problems, and eventually started hacking the
Rosegarden exporter.  In truth, I realized, Rosegarden is a
*sequencer*, and I was demanding too many notational features for a
tool of its purpose.  "If only I could write a command line processor
in Python..."

* Caveats *
The parser, in theory, is supposed to exactly mimic the Lilypond
typesetter and offer an identical grammar.  In reality, it is not
quite that simple.  

* compiling *
Lilytool uses boost::spirit, boost::fusion, and boost::python
extensively.  As such, it brutalizes your C++ compiler.  I'm not sure
which compilers work, but a newer one cannot hurt.  Initial
development used gcc 4.5.3, and migrated to 4.6.2.  Both appear to
work fine.

GCC offers a helpful "internal compiler error".  This started after
Lilytool exceeded some size.  For me, this is required at the shell:
ulimit -s 128000
where the stacksize 128000 some arbitrary large number.

* hacking *

Boost::spirit is a very difficult environment to work in. The main
problem is the lack of useful error messages from the C++ compiler
(they are usually typing errors).  If you are inclined to hate C++,
object to operator overloading "abuse", or dislike any other aspect of
modern C++, don't even dig here (it will protect your sanity).
Compile times are long.  On the other hand, the executable seems to be
quite fast and the source code is compact and expressive.

I welcome collaborators (and would even hand off leadership if
somebody finds this tool useful but still too limited), but quite
frankly, you will not get very far modifying the source code without a
deep, sincere interest in advanced C++ programming.  You have to be an
expert in C++, Python, and Lilypond all at once, to get anywhere other
than frustrated.