Modifying context plug-ins - GNU LilyPond
Description: GNU LilyPond

Next: Layout tunings within contexts, Previous: Changing context properties on the fly, Up: Interpretation contexts

#### 9.2.3 Modifying context plug-ins

Notation contexts (like `Score` and `Staff`) not only store properties, they also contain plug-ins called “engravers” that create notation elements. For example, the `Voice` context contains a `Note_head_engraver` and the `Staff` context contains a `Key_signature_engraver`.

For a full a description of each plug-in, see Engravers. Every context described in Contexts lists the engravers used for that context.

It can be useful to shuffle around these plug-ins. This is done by starting a new context with `\new` or `\context`, and modifying it,

    \new context \with {
      \consists ...
      \consists ...
      \remove ...
      \remove ...
      etc.
    }
    {
      ..music..
    }

where the ... should be the name of an engraver. Here is a simple example which removes `Time_signature_engraver` and `Clef_engraver` from a `Staff` context,

>          <<
>            \new Staff {
>              f2 g
>            }
>            \new Staff \with {
>               \remove "Time_signature_engraver"
>               \remove "Clef_engraver"
>            } {
>              f2 g2
>            }
>          >>

In the second staff there are no time signature or clef symbols. This is a rather crude method of making objects disappear since it will affect the entire staff. This method also influences the spacing, which may or may not be desirable. A more sophisticated method of blanking objects is shown in Common tweaks.

The next example shows a practical application. Bar lines and time signatures are normally synchronized across the score. This is done by the `Timing_translator` and `Default_bar_line_engraver`. This plug-in keeps an administration of time signature, location within the measure, etc. By moving thes engraver from `Score` to `Staff` context, we can have a score where each staff has its own time signature.

>          \new Score \with {
>            \remove "Timing_translator"
>            \remove "Default_bar_line_engraver"
>          } <<
>            \new Staff \with {
>              \consists "Timing_translator"
>              \consists "Default_bar_line_engraver"
>            } {
>                \time 3/4
>                c4 c c c c c
>            }
>            \new Staff \with {
>              \consists "Timing_translator"
>              \consists "Default_bar_line_engraver"
>            } {
>                 \time 2/4
>                 c4 c c c c c
>            }
>          >>

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

Other languages: English.
Using automatic language selection.