4.3.5 Ábrázolók hozzáadása és eltávolítása

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'4
  \set fontSize = #-4  % make note heads smaller
  d e
  \set fontSize = #2.5  % make note heads larger
  f g
  \unset fontSize  % return to default size
  a b
}

[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 {
    \voiceOne
    c'' a b g
  }
  \new Voice
  \relative {
    \voiceTwo
    c' 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 {
    \voiceOne
    c'' a b g
  }
  \new Voice
  \relative {
    \voiceTwo
    c' 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'' a b g
      }
    >>
    \new Staff <<
      \relative {
        c' a b g
      }
    >>
    \new Staff <<
      \clef "G_8"
      \relative {
        c' a b g
      }
    >>
    \new Staff <<
      \clef "bass"
      \relative {
        c 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.

Lásd még

A kottaírás kézikönyve: Modifying context plug-ins, Changing context default settings.


LilyPond — Tankönyv v2.24.4 (stable-branch).