[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

Tuning groups of objects

A object definition is a Scheme association list, that is stored in a context property. By assigning to that property (using plain \property), you can change the resulting objects.

     c'4 \property Voice.NoteHead  = #'() c'4
     
[picture of music]
This mechanism is fairly crude, since you can only set, but not modify, the definition of an object. Also, it will thoroughly confuse LilyPond.

The definition of an object is actually a list of default object properties. For example, the definition of the Stem object (available in scm/grob-description.scm), includes the following definitions for Stem

             (thickness . 0.8)
             (beamed-lengths . (0.0 2.5 2.0 1.5))
             (Y-extent-callback . ,Stem::height)
             ...
     

You can add a property on top of the existing definition, or remove a property, thus overriding the system defaults:

     c'4 \property Voice.Stem \override #'thickness = #4.0
     c'4 \property Voice.Stem \revert #'thickness
     c'4
     
[picture of music]
You should balance \override and \revert. If that's too much work, you can use the \set shorthand. It performs a revert followed by an override. The following example gives exactly the same result as the previous one.
     c'4 \property Voice.Stem \set #'thickness = #4.0
     c'4 \property Voice.Stem \set #'thickness = #0.8
     c'4
     
[picture of music]
If you use \set, you must explicitly restore the default.

Formally the syntax for these constructions is

     \property context.grobname \override symbol = value
     \property context.grobname \set symbol = value
     \property context.grobname \revert symbol
     
Here symbol is a Scheme expression of symbol type, context and grobname are strings and value is a Scheme expression.

If you revert a setting which was not set in the first place, then it has no effect. However, if the setting was set as a system default, it may remove the default value, and this may give surprising results, including crashes. In other words, \override and \revert, must be carefully balanced.

These are examples of correct nesting of \override, \set, \revert.

A clumsy but correct form:

       \override \revert \override \revert \override \revert
     

Shorter version of the same:

       \override \set \set  \revert
     

A short form, using only \set. This requires you to know the default value:

       \set \set \set \set to default value
     

If there is no default (i.e. by default, the object property is unset), then you can use

       \set \set \set \revert
     

For the digirati, the object description is an Scheme association list. Since a Scheme list is a singly linked list, we can treat it as a stack, and \override and \revert are just push and pop operations. This pushing and popping is also used for overriding automatic beaming settings.

BUGS

LilyPond will hang or crash if value contains cyclic references. The backend is not very strict in type-checking object properties. If you \revert properties that are expected to be set by default, LilyPond may crash.

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.