Interpretation contexts - GNU LilyPond
Description: GNU LilyPond

Next: The \override command, Previous: Automatic notation, Up: Changing defaults

### 9.2 Interpretation contexts

When music is printed, a lot of notational elements must be added to the input. For example, compare the input and output of the following example:

>          cis4 cis2. g4

The input is rather sparse, but in the output, bar lines, accidentals, clef, and time signature are added. LilyPond interprets the input. During this step, the musical information is inspected in time order, similar to reading a score from left to right. While reading the input, the program remembers where measure boundaries are, and which pitches require explicit accidentals. This information can be presented on several levels. For example, the effect of an accidental is limited to a single staff, while a bar line must be synchronized across the entire score.

Within LilyPond, these rules and bits of information are grouped in Contexts. Some examples of contexts are `Voice` , `Staff` , and `Score` . They are hierarchical, for example: a `Staff` can contain many `Voice` s, and a `Score` can contain many `Staff` contexts.

Each context has the responsibility for enforcing some notation rules, creating some notation objects and maintaining the associated properties. For example, the `Voice` context may introduce an accidental and then the `Staff` context maintains the rule to show or suppress the accidental for the remainder of the measure. The synchronization of bar lines is handled at `Score` context.

However, in some music we may not want the bar lines to be synchronized – consider a polymetric score in 4/4 and 3/4 time. In such cases, we must modify the default settings of the `Score` and `Staff` contexts.

For very simple scores, contexts are created implicitly, and you need not be aware of them. For larger pieces, such as anything with more than one staff, they must be created explicitly to make sure that you get as many staves as you need, and that they are in the correct order. For typesetting pieces with specialized notation, it can be useful to modify existing or to define new contexts.

A complete description of all available contexts is in the program reference, see Contexts.

This page is for LilyPond-2.8.8 (stable-branch).

Other languages: English.
Using automatic language selection.