[icon]

GNU LilyPond

-- --

What is LilyPond
Home
Examples
Templates
Download
GNU/Linux binaries
Windows binaries
Source code
Documentation
Tutorial
Manual
Glossary
Index

Support
Mailing lists
Search
WikiWiki

External sites
lilypond.org/stable
lilypond.org/development
savannah.gnu.org
ftp.lilypond.org
Mutopia
Other music online

Horizontal Spacing

The spacing engine translates differences in durations into stretchable distances ("springs") of differing lengths. Longer durations get more space, shorter durations get less. The basis for assigning spaces to durations, is that the shortest durations get a fixed amount of space, and the longer durations get more: doubling a duration adds a fixed amount of space to the note.

For example, the following piece contains lots of half, quarter and 8th notes, the eighth note is followed by 1 note head width. The The quarter note is followed by 2 NHW, the half by 3 NHW, etc.

      c2 c4. c8 c4. c8 c4. c8 c8 c8 c4 c4 c4
     
[picture of music]

These two amounts of space are shortest-duration-space spacing-increment, object properties of SpacingSpanner . Normally spacing-increment is set to 1.2, which is the width of a note head, and shortest-duration-space is set to 2.0, meaning that the shortest note gets 2 noteheads of space. For normal notes, this space is always counted from the left edge of the symbol, so the short notes in a score is generally followed by one note head width of space.

If one would follow the above procedure exactly, then adding a single 32th note to a score that uses 8th and 16th notes, would widen up the entire score a lot. The shortest note is no longer a 16th, but a 64th, thus adding 2 noteheads of space to every note. To prevent this, the shortest duration for spacing is not the shortest note in the score, but the most commonly found shortest note. Notes that are even shorter this are followed by a space that is proportonial to their duration relative to the common shortest note. So if we were to add only a few 16th notes to the example above, they would be followed by half a NHW:

      c2 c4. c8 c4. [c16 c] c4. c8 c8 c8 c4 c4 c4
     
[picture of music]

The most common shortest duration is determined as follows: in every measure, the shortest duration is determined. The most common short duration, is taken as the basis for the spacing, with the stipulation that this shortest duration should always be equal to or shorter than 1/8th note. The shortest duration is printed when you run lilypond with --verbose. These durations may also be customized. If you set the common-shortest-duration in SpacingSpanner , then this sets the base duration for spacing. The maximum duration for this base (normally 1/8th), is set through base-shortest-duration.

In the introduction it was explained that stem directions influence spacing. This is controlled with stem-spacing-correction in NoteSpacing . The StaffSpacing object contains the same property for controlling the stem/barline spacing. In the following example shows these corrections, once with default settings, and once with exaggerated corrections.

[picture of music]

BUGS

Spacing is determined on a score wide basis. If you have a score that changes its character (measured in durations) half way during the score, the part containing the longer durations will be spaced too widely.

Generating optically pleasing spacing is black magic. LilyPond tries to deal with a number of frequent cases. Here is an example that is not handled correctly, due to the combination of chord collisions and kneed stems.

[picture of music]
Go back to index of LilyPond.

Please send GNU LilyPond questions and comments to lilypond-user@gnu.org.

Please send comments on these web pages to (address unknown)

Copyright (c) 1997--2002 Han-Wen Nienhuys and Jan Nieuwenhuizen.

Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved.


This page was built from LilyPond-1.7.14 (development-branch) by

Buchan Milne <(address unknown)>, Thu Mar 6 21:11:35 2003 CET.