[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using lilypond as a music layout library

From: Erik Sandberg
Subject: Re: Using lilypond as a music layout library
Date: Thu, 13 Sep 2007 19:37:40 +0200
User-agent: KMail/1.9.6

On Tuesday 11 September 2007, Tom Shackell wrote:
> Hi All,
> I was wondering whether it would be possible to extract lilypond's
> layout code and use it as a general library for performing music layout.
> That is to say a programmer would pass lilypond unformatted musical
> notation (as a data structure) and lilypond would perform layout and
> return the data structure now with positional information for all the
> components.
> The reason this would be desirable is that laying out music nicely is
> difficult and lilypond is well known for the quality of its output.
> Someone wanting to write a WYSIWYG GUI for note-editing (for example)
> could then re-use all the hard work that has gone in lilypond to do the
> layout of the music on the screen.
> Theoretically this should be possible. I would imagine that Lilypond's
> code is split into:
>     - parsing and processing .ly files
>     - laying out the musical notation
>     - converting the notation with layout into output of some form
>       (for example postscript).

You may be interested in reading my master thesis (it's available 
under 'publications' somewhere on the lily web page). It discusses the 
separation of lily into language and music formatter.

> It would, in principal at least be possible to separate the part that
> performs layout from the rest of the code. However there are several
> practical concerns:
>     - the modularity of lilypond's design. It could simply be that
>       lilyponds components are too tightly integrated to make this
>       separation possible.

No, this has been fixed.

>     - incremental layout. For the purposes of producing a GUI
>       it would have to be possible to perform incremental layout to some
>       degree. At least to the point of only asking lilypond to
>       recalculate layout the current bar/line/page. It is possible
>       lilypond has been written assuming a 'one-shot' approach in which
>       case making lilypond work incrementally would be almost impossible.

This is probably the biggest problem, but should be doable.

>     - performance generally. An interactive editor would need to perform
>       layout with relatively good performance. Incremental layout is
>       perhaps the biggest component here but it could be that lilypond is
>       simply too slow for this kind of task.

Probably true. Once incremental layout is in place, it may be possible to 
limit the problem by only updating the music locally (on the currently 
displayed page), ignoring the fact that local changes may affect the 
typesetting on other pages as well.

Note also that there is an experimental builtin gnome back-end to lily. It can 
be used to graphically tweak the positions of individual objects.

> One point is that even if the entire layout engine could not be
> extracted parts of the algorithm could still be useful. For example
> perhaps only having the code to do 'vertical' layout, i.e. deciding how
> notation on the beat-line should be arranged, even if the horizontal
> layout of the beat-line is undefined.
> So anyway I would be interested to know whether people think extracting
> the layout code is feasible or is broadly impossible/impractical.

To sum up: The layout code is fairly extracted already; the postscript 
back-end and textual front-end are exchangable already. The largest problem 
is that incremental layout isn't possible yet, so a welcome addition would be 
to adjust the existing system to support that, as a first step.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]