### 4.2 Interpretation contexts

When music is printed, a lot of notation elements must be added to the input, which is often bare bones. 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 program remembers where measure boundaries are, and what pitches need explicit accidentals. This information can be presented on several levels. For example, the effect of an accidental is limited to a single stave, while a bar line must be synchronized across the entire score.

Within LilyPond, these rules and bits of information are grouped in so-called Contexts. Examples of context 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. So, the synchronization of bar lines is handled at `Score` context. The `Voice` may introduce an accidentals and then the `Staff` context maintains the rule to show or suppress the accidental for the remainder of the measure.

For simple scores, contexts are created implicitly, and you need not be aware of them. For larger pieces, such as piano music, 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 define new contexts.

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

Read comments on this page, or add one. This page is for LilyPond-2.2.5 (stable-branch).