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



9.1.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 like this,

\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
       }
     >>

[image of music]

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. The spacing is adversely influenced too. 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_engraver. This plug-in keeps an administration of time signature, location within the measure, etc. By moving the Timing_engraver engraver from Score to Staff context, we can have a score where each staff has its own time signature.

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

[image of music]

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

Report errors to <bug-lilypond@gnu.org>.

Other languages: English.
Using automatic language selection.