3.3.5 Adding and removing engravers

We have seen that contexts each contain several engravers, each of which is responsible for producing a particular part of the output, like bar lines, staves, note heads, stems, etc. If an engraver is removed from a context, it can no longer produce its output. This is a crude way of modifying the output, but it can sometimes be useful.

Changing a single context

To remove an engraver from a single context we use the \with command placed immediately after the context creation command, as in the previous section.

As an illustration, let’s repeat an example from the previous section with the staff lines removed. Remember that the staff lines are produced by the Staff_symbol_engraver.

\new Staff \with {
  \remove "Staff_symbol_engraver"
}
\relative c' {
  c4 d
  \set fontSize = #-4  % make note heads smaller
  e4 f |
  \set fontSize = #2.5  % make note heads larger
  g4 a
  \unset fontSize  % return to default size
  b4 c |
}

[image of music]

Engravers can also be added to individual contexts. The command to do this is

\consists Engraver_name,

placed inside a \with block. Some vocal scores have an ambitus placed at the beginning of a staff to indicate the range of notes in that staff – see ambitus. The ambitus is produced by the Ambitus_engraver, which is not normally included in any context. If we add it to the Voice context, it calculates the range from that voice only:

\new Staff <<
  \new Voice \with {
    \consists "Ambitus_engraver"
  } {
    \relative c'' {
      \voiceOne
      c4 a b g
    }
  }
  \new Voice {
    \relative c' {
      \voiceTwo
      c4 e d f
    }
  }
>>

[image of music]

but if we add the ambitus engraver to the Staff context, it calculates the range from all the notes in all the voices on that staff:

\new Staff \with {
  \consists "Ambitus_engraver"
}
<<
  \new Voice {
    \relative c'' {
      \voiceOne
      c4 a b g
    }
  }
  \new Voice {
    \relative c' {
      \voiceTwo
      c4 e d f
    }
  }
>>

[image of music]

Changing all contexts of the same type

The examples above show how to remove or add engravers to individual contexts. It is also possible to remove or add engravers to every context of a specific type by placing the commands in the appropriate context in a \layout block. For example, if we wanted to show an ambitus for every staff in a four-staff score, we could write

\score {
  <<
    \new Staff {
      \relative c'' {
        c4 a b g
      }
    }
    \new Staff {
      \relative c' {
        c4 a b g
      }
    }
    \new Staff {
      \clef "G_8"
      \relative c' {
        c4 a b g
      }
    }
    \new Staff {
      \clef "bass"
      \relative c {
        c4 a b g
      }
    }
  >>
  \layout {
    \context {
      \Staff
      \consists "Ambitus_engraver"
    }
  }
}

[image of music]

The values of context properties may also be set for all contexts of a particular type by including the \set command in a \context block in the same way.

See also

Notation Reference: Modifying context plug-ins, Changing context default settings.

Known issues and warnings

The Stem_engraver and Beam_engraver attach their objects to note heads. If the Note_heads_engraver is removed no note heads are produced and therefore no stems or beams are created either.


Other languages: česky, deutsch, español, français, magyar, italiano, 日本語, nederlands.
About automatic language selection.

LilyPond — Learning Manual v2.17.97 (development-branch).