Greetings everybody, and welcome to this twenty-fourth issue of the LilyPond Report!
First things first: this slightly unusual issue features a rather important request from our co-editor David Kastrup, who also happens to be arguably the most involved and efficient LilyPond developer at the moment — and unarguably, our only full-time developer. Also featured in this issue is an overview of some aspects of the new, simplified syntax in LilyPond. At last, we’ll be discussing a long-overdue topic, to wit: LilyPond-based web applications, with a long-overdue contribution from scorio.com founder Johannes Feulner!
As always, you can post your comments at the bottom of the page, or send your contributions to the LilyPond Report’s next issues.
by Valentin Villenave & Graham Percival.
The LilyPond Report was started exactly four years ago this month; although it has been a bumpy ride, with occasional long periods of inactivity, we hope it has proven a valuable medium for the GNU LilyPond project and the Free software world in general. It has given us a chance to meet dozens of interesting developers and contributors, to address various music-related questions and to provide a hindsight into LilyPond’s development process. This month however, we are contributing to the LilyPond project in a new, more serious way, upon request from our co-editor and colleague David Kastrup.
While several projects depending on LilyPond have managed to fund full-time developers, LilyPond development itself has not really seen significant monetary support from its users so far. Every so often, however, users ask if they can contribute financially to
LilyPond. Creating a single legal entity to handle such matters
would raise a number of legal and administrative problems which we
are not equipped to handle at the moment. However, we have a
specific place where developers can indicate their interest in
private arrangements:
http://lilypond.org/sponsoring.html
Currently the only developer on this page is David. As you can see from the git statistics, he has been very active over the past few months. Both his self-chosen projects as well as the expertise he has provided for work on our infrastructure and the projects of others have given LilyPond an important push forward.
As you can see in his plea below, David is in dire financial straits. Unless he receives money to support his LilyPond work, he will need to leave the project and find work elsewhere — which would be bad news for LilyPond.
Users of LilyPond, contributors and enthusiasts, you now have the chance to secure an important contributor for full-time work. If you are interested in supporting LilyPond financially, we warmly suggest that you sponsor David to fix bugs or add features that interest you.
On a personal note, both of us have unrelatedly sponsored David to add new features for us in the past, and in both cases his work was fast and high-quality.
Graham Percival, GNU LilyPond project manager;
Valentin Villenave, LilyPond newsletter editor.
David Kastrup
by Valentin Villenave.
Although LilyPond’s next stable release, 2.16, is getting nearer every day, it will take a little more time and intermediate "development" versions. As we were hoping to release 2.16 in early March 2012, a number of new critical issues have been found, thereby delaying the release. The good news is, these issues are now solved and we’re ready to proceed with the development cycle — that is, at least one more Release Candidate will be needed.

Speaking of which, it is important to point out that, as 2.16 is looming, you should test the release candidate — by "you" we mean all users, not just the most adventurous ones: the more people test it and report any problem, regressions or unwanted behavior, the more our "stable" release will be worthy of that name. So, please download and install our release candidate!
What will this new stable version bring to the table? We’ll take an in-depth look later on, but here is a complete list of the most noteworthy changes, be sure to check it out and discover LilyPond’s new, exciting features!
Please also note that the LilyPond team is currently in need of a new Mac OS X maintainer. This LilyPond port definitely needs some love, and it has proven hard for regular developers to keep up with Apple’s latest broken incompatible absurd fancy new features. If you’re experienced enough (both with LilyPond build process and the Mac OS X environment) and feel up to the task, please don’t wait and get in touch!
Some LilyPond Parser Changes:
Recent Work and Plans
by David Kastrup.
LilyPond’s parser is written using the parser generator "Bison’’.
Bison generates parsers of the LALR(1) class which basically means
that it makes its parsing decisions by considering a set of rules like
property_operation: STRING '=' scalar
| "\unset" simple_string
| "\override" simple_string property_path '=' scalar
| "\revert" simple_string embedded_scm
(the LilyPond grammar can be found formatted in that way in the
Notation Reference). It gets "tokens’’ (such as integers,
inter-punctuation characters, complete words, note names) as input, and makes its decisions about which rule to apply next based on the
combination of its current state (of which there are about 700
distinct ones), the production on the top of a push-down stack, and
sometimes by looking at the next token. When it applies a rule, it
may execute actions associated with that rule, and when it has reduced
everything to the first rule (the start rule) it is finished.
For a compiler, the actions are commonly used for generating code, or as a first step to that purpose, a parse tree representing the input. In contrast, LilyPond works mostly as an interpreter. This means that it executes the actions associated with input as soon as it is able to exercise a rule.
Turning the LilyPond input language into a compiler would present
considerable challenges because of the design of the language: some
decisions, like assigning a syntactic class to an escaped
\keyword or an immediate Scheme expression such
as $(ly:make-pitch 0 0 0) are inherently dependent on the current state as evolved by the interpreter.
However, the purpose of the input language is almost exclusively limited to parsing and generating music lists; and actually transforming those lists into a printed representation via engravers and Midi via performers is what takes the bulk of processing time.
Parser developments
Optional music function arguments
Since the last stable versions (2.14), music functions with optional
arguments have made it into LilyPond. One result has been that a number of syntactic constructs hardwired into LilyPond’s grammar could be turned into music functions. For example, in LilyPond 2.14, the command \relative was parsed in the LilyPond
grammar with the rule
relative_music:
RELATIVE absolute_pitch music {
Pitch start = *unsmob_pitch ($2);
$$ = make_music_relative (start, $3, @$);
}
| RELATIVE composite_music {
Pitch middle_c (0, 0, 0);
$$ = make_music_relative (middle_c, $2, @$);
}
;
Now it is parsed using the following definition:
relative =
#(define-music-function (parser location pitch music)
((ly:pitch? (ly:make-pitch 0 0 0)) ly:music?)
(_i "Make @var{music} relative to @var{pitch} (default @code{c'}).")
(ly:make-music-relative! music pitch)
(make-music 'RelativeOctaveMusic
'element music))
For one thing, having fewer hard-coded exceptions makes the syntax more regular. For another, the functionality is now documented in the notation reference together with other music functions (the given documentation string is tunneled there in the process of creating the manuals). Another advantage is that changing the functionality does not require recompilation of LilyPond.
More importantly, users can now create functionality in Scheme (and thus as part of writing a LilyPond source file) that formerly required changing and recompiling the parser.
The workhorse #{ ... #}
In 2.14, you could employ the construct #{ ... #} for writing sequential music in Scheme. It has been slightly extended to also allow writing pitches, markups, scores, books and bookparts, single music expressions, postevents, context definitions, layout definitions and some other things. Basically, it has turned into a general interface for specifying details in LilyPond syntax when writing in Scheme, and, as one example, now provides a user-friendly alternative for the markup macro. markup is a tricky construct for writing markups with a syntax that is almost, but not quite, entirely unlike LilyPond.
Previously, there was a special interface using $ for
getting material from local variables into #{ ... #}. Some aspects of it have been turned into a general feature ("immediate’’ Scheme expressions) available throughout LilyPond, but more importantly, all Scheme expressions inside of #{ ... #} are evaluated in `lexical closure’, meaning that they can access the local variables of surrounding Scheme code. So #{ ... #} has turned into a quite more powerful feature, at the same time behaving more like `regular’ LilyPond.
If we take the above example for relative music and change it such
that the default will be to make the music relative to f
(which means that the first note will actually be written with
absolute pitch), we can call this \ablative (because it starts
out as absolute, and continues relative):
ablative =
#(define-music-function (parser location pitch music)
((ly:pitch? #{ f #}) ly:music?)
#{ \relative $pitch #music #})
We did a few things here typical for user-defined functions: there is
little point in a documentation string, and we generously employ #{ ... #}.
Actually, since \relative remains available, there is little point in accepting an optional pitch argument here, but it makes for a somewhat more interesting example.
Using #{ ... #} extensively makes it possible to employ Scheme mostly as glue code between LilyPond fragments.
Future developments
Further unification of argument types
At the current point of time, there are still two argument types
recognized separately in the grammar: ly:duration? and
ly:pitch?. As a result, the last example had to use an
immediate Scheme expression $pitch (as otherwise the argument would have been interpreted as type "Scheme’’), while it was possible to write #music since arguments of type music and of type Scheme are interchangeable already, relying only on evaluation of the predicate for type checking.
Removing those special argument types provides a bit of a challenge. Pitches are challenging because a pitch is a valid start of a music expression (and that implies a bit of incremental parsing to make them fit with the general scheme of things since one does not want to recognize pitches using lookahead in optional argument settings, and pitches can contain an arbitrary number of octave marks).
Durations are challenging in a similar manner because of being able to be confused with numbers, because of optional following dots, and partly because they can become part of a preceding music expression such as when preceded by a pitch.
Removal of "closed music’’ category
At the current point of time, music arguments before durations or
after skipped optional arguments need to be enclosed in braces or
other delimiters in order to avoid ambiguities in the interpretation
of things like c 8: is the 8 part of the music argument, or is it a duration following it? And an optional music function argument has to be first created, then checked against its predicate, and if that does not match, backed up in the grammar. And in a stateful parser like that of LilyPond, backing up is only possible
when the parser has not seen further tokens and/or has entered
into states depending on them.
Some of the more recent changes in the LilyPond parser have been in the area of resolving such ambiguities by looking at the context and potentially backtracking and/or parsing stuff incrementally.
The principal idea is that one parses first tentatively without lookahead, and checking possible expression types that can arise against the optional argument predicates, even though the actual expression might not be complete. This means that the argument predicates must not have side-effects, but just depend on their arguments, a reasonable assumption.
However, when the expression itself results from a music or scheme
function call, the amount of possible reparsing is limited since
requiring music or scheme functions to be without side-effect would be
excessive: for example the main point of \displayMusic is its side effect. So if
\displayMusic is in itself a potentially
optional argument of a music function, we either have to be able to
parse its argument without lookahead, or we won’t be able to back it
up again in case it is not accepted by the optional argument
predicate.
As one example, a \repeat construct at the current point of time is not closed music, because LilyPond needs to be able to parse an item without lookahead when it may or may not accept it as
an optional argument. And a \repeat construct may be followed by \alternatives, something that is impossible to see without lookahead. The solution is to first parse just up to the conclusion of the \repeat, and then call the optional argument predicate on the resulting music expression. If it is found acceptable, LilyPond can resume parsing after having made the decision that it will not skip this optional argument, and the resumed parsing can now work using lookahead tokens freely. If it turns out that the construct with alternatives is not acceptable
any more, we blame the user (meaning that we don’t deal with
surprising amounts of backtracking).
Removing the concept of "closed music’’ (or at least reducing its
impact) would reduce the number of things a user has to understand in
order to create and use music functions. Here is one example of a
set-back: at some point of time, \displayMusic was given an optional port argument before the music expression. Since only closed music expressions are allowed after a skipped optional argument, \displayMusic c'' ceased being valid input, a side effect discovered more than a week after making the change. The change has been reverted for now, but at one point of time, it should be possible to bring it back without such repercussions.
The idea is to have the user just see results equivalent to greedy and
backtracking parsing compatible with evaluating the given music
function predicates: this is conceptually easy to understand, explain,
and extend, but mapping this into code that can be tackled by an
LALR(1) parser generator is challenging.
by Valentin Villenave.
Although some of our youngest readers may not remember, there actually was a time, not too many years ago, where people did rely on their computers to do their computing, where your phone’s primary use was to make phone calls, where using a webmail service was considered bad taste (and JavaScript, an unnecessary ugliness), where thin clients were regarded as subpar computers to be used exclusively in a corporate environment and usually meant your boss was kinda cheap; a time where the "cloud computing" buzzword — can you imagine — didn’t even exist!
One of LilyPond’s major downsides when it comes to dealing with inexperienced users, and probably one of the reasons why it hasn’t seen more widespread adoption amongst musicians, is its setup process that may seem peculiar to people unfamiliar with the notion of "source code". Installing LilyPond itself has become increasingly easy over the years; setting up your work environment (text editor, PDF preview, command-line invocation) is a bit more involved... assuming you can think about it: I can’t count the people around me to whom it has never occurred that they could actually be using something else than the default NotePad application for Windows™, or the LilyPad text editor we provide for Mac OS X.
In this regard, being given the ability to discover the full potential of LilyPond (including syntax-colored source code and score preview) in a Web browser without having to install anything whatsoever, may be an excellent introduction. As early as 2006, a notorious visionary — namely, myself — predicted that "LilyPond’s future might well be web-oriented". I wasn’t, to be fair, the first one: in January 2005, Sebastiano Vigna had introduced the LilyPond Snippet Repository that provided the very first public LilyPond server. The LSR was intended for documentation purposes and required a bit of work to get around its ERW-based interface, but it is still in use today.
Setting it up, to be honest, is quite an involved task and demands more than just courage, but also a bit of masochism and recklessness. By that I am not only referring to Sebastiano’s peculiar taste in terms of server-side Java, but the main point is that LilyPond, as a program and as a language, presents an extreme security risk for any server where you want to run it. Since it allows for embedded Scheme, that in turn can convey system calls, it can — and will eventually, if you leave it open to anyone on the interwebs — wipe out your system and kill your hamster! That’s not the only issue: even perfectly harmless code can eat up a considerable amount of resources, there’s also the problem of \include instructions that would require users to upload multiple files and thereby multiply injection risks, etc.
In short: children, do not do it at home!
But that kind of warnings has never stopped any self-respecting geek, has it?
Interestingly enough, all of the subsequent prototypes, based on Sebastiano’s work, weren’t conceived as standalone web-applications, but rather tried integrate LilyPond into existing Content Management Systems. In 2006 Chris Lamb came up with a Wordpress plugin; slightly later our developer and git expert Johannes Schindelin introduced a MediaWiki extension that raised a lot of eyebrows (man, LilyPond in Wikipedia! — hold your horses, more on that later). In 2007, Christophe Richard also turned it into a plugin for the SPIP cms, and it was even added as a plugin to the FCK editor. Last but not least, in 2009 Harmath Dénes integrated LilyPond into Google Wave® the brand-new disruptively-sexy Next Big Thing that was gonna revolutionize the world as we knew it.
In May 2007, I had introduced the first prototype of an online real-time syntax-highlighting and auto-indenting LilyPond editor. It was mostly a hack around the Codepress Javascript editor, but it was fun to make and it became part of a French effort to provide LilyPond-ready web applications (around the now-defunct lilyserv.net server, modeled after Sebastiano’s code). We were beginning to discuss a possible standalone web-application (a then new-and-shiny buzzword, as Gmail&Co were gaining traction). Laurent Ducos even suggested it should sport an online graphical interface such as Denemo or LilyComp, but that never went anywhere.
Then came what I’d refer to as the "second generation" of LilyPond-based online efforts: the era of standalone, user-friendly web applications. In this regard, the year 2010 certainly was some kind of a turning point. The iPhone® (and its useless brother the iPad®) was everywhere, and running LilyPond on it wouldn’t have been an option; taking advantage of that, a Daniel Glover released the proprietary, LilyPond-reliant Etude App, that is said to have sold quite well. For those of us who don’t have an Apple product and actually care about the open Web, the same year Mike Blackstock (after having tried to set up a LilyPond-friendly wiki — in vain ) announced the availability of a collection of online music editing tools, aptly named OMET. Then there was also LilyPondTool contributor Joshua Koo and his project (beware, that’s a Facebook link) of a "Google Docs for music" that became JabTunes (the homepage is ugly and contains some Flash, but check out his labs for some pretty nifty HTML5 experiments). Finally, the new kid on the block has been announced quite recently by Trevor Dixon as Lilybin, that looks quite promising. I’ve also seen other people (including Dominic Neumann, Eric Knapp, Philip Peterson) announce that they were working on online web interfaces for LilyPond; there definitely is a growing trend here.
As early as May 2009, an unidentified developer appeared to be working on a project called WebLily. It wasn’t made public until March 2010, as a LilyPond Report comment, although we still didn’t know (other than through whois) who was behind it. Learning about it made LilyPond project manager Graham Percival unusually enthusiastic:
Interesting! Never heard of it before. [...] I have to admit that at first I was expecting tons of advertizing (I have a nasty mind), but it all looks legit. The "clickable notation reference" is a neat idea.
(Evidently, Graham’s usual grumpy self took over soon thereafter, as he roasted "Mr. WebLily" for his alleged disregard of security risks. [Update: he then apologized, but his concerns were nothing if not legitimate in the first place.])
"Mr. WebLily" soon appeared to have a name, as he not only maintained his WebLily service but also launched a new, more commercial service: Scorio.com — although LilyPond isn’t credited prominently on this new website. Johannes Feulner — founder of WebLily and Scorio — also happens to be one of our readers, and he generously sent us the following contribution more than a year ago.
Thanks to Johannes for this contribution!
So, what’s coming next for "cloud-oriented" LilyPond applications? It certainly is too early to tell, but if history has taught us anything, it’s that the LilyPond community closely and strikingly follows the general trends in computing and software development (both Free and proprietary), so we can safely assume that online music interfaces aren’t going anywhere anytime soon. — A trend that’s also taken by our friends at MuseScore. On the WYSIWYG side, I’ve also noticed with great interest that Jan Nieuwenhuizen’s Schikkers List, which we introduced last year, is based on the GTK3 toolkit, that has an HTML canvas backend. Just sayin’.
Another point that shouldn’t be overlooked, is of an ethical matter. Free software advocates have been warning about the dangers of "cloud computing" and entrusting any third-party (particularly of a private/commercial nature, with the degree of instability and unforeseen policy changes it may imply) with your data. Granted, a music score hardly contains as much personal confidential information as, say, your email account; nevertheless I for one wouldn’t ever store my music scores on a webserver that isn’t owned by me or a non-profit community I know and trust — not without a solid local backup, at least.
As I said above, a point certainly can be made that such Web-applications provide an excellent introduction to GNU LilyPond, and a great way of working together on music scores. That is, assuming people know the app they’re using is powered by LilyPond: while it is mentioned on scorio (albeit not prominently), I couldn’t find any mention whatsoever on EtudeApp.com. If anything, we must stay vigilant and make sure LilyPond remains freely and easily accessible other than through proprietary overlays; we also should encourage developers of such web applications to make use of Free licenses whenever they can, knowing that it won’t drive people away but on the contrary gain support amongst Free software enthusiasts and the LilyPond community at large!
In our previous installment, we mentioned that some rather simple syntax had been deprecated for several years. However, it turns our that current developments allowed for a further simplification of the LilyPond example presented in the article "Prelude #1 in Scheme". Check it out under this link.

That concludes the twentyfourth installment of the LilyPond Report. Our special guest next month will be Janek Warchoł, a young, enthusiastic LilyPond contributor who’ll share with us his passion and ideas. Stay tuned!
Cheers,
Graham Percival, David Kastrup & Valentin Villenave.