4.3.3 Engravers explained

Every mark on the printed output of a score produced by LilyPond is produced by an Engraver. Thus there is an engraver to print staves, one to print note heads, one for stems, one for beams, etc., etc. In total there are over 140 such engravers! Fortunately, for most scores it is not necessary to know about more than a few, and for simple scores you do not need to know about any.

Engravers live and operate in contexts. Engravers such as the Metronome_mark_engraver, whose action and output apply to the score as a whole, operate in the highest level context – the Score context.

The Clef_engraver and Key_engraver are to be found in every Staff context, as different staves may require different clefs and keys.

The Note_heads_engraver and Stem_engraver live in every Voice context, the lowest level context of all.

Each engraver processes the particular objects associated with its function, and maintains the properties that relate to that function. These properties, like the properties associated with contexts, may be modified to change the operation of the engraver or the appearance of those elements in the printed score.

Engravers all have compound names formed from words that describe their function. Just the first word is capitalized, and the remaining words are joined to it with underscores. Thus the Staff_symbol_engraver is responsible for creating the lines of the staff, the Clef_engraver determines and sets the pitch reference point on the staff by drawing a clef symbol.

Here are some of the most common engravers together with their function. You will see it is usually easy to guess the function from the name, or vice versa.

EngraverFunction
Accidental_engravermakes normal, cautionary, and suggested accidentals
Beam_engraverengraves beams
Clef_engraverengraves clefs
Completion_heads_engraversplits notes that cross bar lines
Dynamic_engravercreates hairpins and dynamic texts
Forbid_line_break_engraverprevents line breaks if a musical element is still active
Key_engravercreates the key signature
Metronome_mark_engraverengraves metronome marking
Note_heads_engraverengraves note heads
Rest_engraverengraves rests
Staff_symbol_engraverengraves the five (by default) lines of the staff
Stem_engravercreates stems and single-stem tremolos
Time_signature_engravercreates time signatures

We shall see later how the output of LilyPond can be changed by modifying the action of engravers.

See also

Internals reference: Engravers and Performers.


LilyPond Learning Manual v2.25.22 (development-branch).