7.1.6 Resaltados en el pentagrama

Para un propósito de análisis o pedagógico, puede ser de utilidad “resaltar” pasajes musicales, por ejemplo para mostrar una región tonal. Esto se puede hacer usando la instrucción \staffHighlight, que recibe un color como argumento. Para conocer todas las formas de introducir colores, see Colorear objetos. El resaltado se finaliza usando \stopStaffHighlight.

\relative {
  \time 2/4
  c'4 4
  \staffHighlight "lightsteelblue"
  g'8( fis g4)-.
  \stopStaffHighlight
  c2
}
[image of music]

Si hay varios resaltados seguidos, no es necesario escibir \stopStaffHighlight, porque \staffHighlight también termina implícitamente el resaltado en curso, si hay uno. De forma similar, no es necesario escibir \stopStaffHighlight al final de la pieza. Esto es especialmente práctico si se quieren resaltar todos y cada uno de los compases.

\relative {
  \time 2/4
  \staffHighlight "lightpink"
  c'4 4
  \staffHighlight "lightsteelblue"
  g'8( fis g4)-.
  \staffHighlight "lightpink"
  c2
}
[image of music]

De forma predeterminada, los pentagramas se resaltan por separado.

music = {
  \time 2/4
  \staffHighlight "lightpink"
  c'4 4
  \staffHighlight "lightsteelblue"
  g'8( fis g4)-.
  \staffHighlight "lightpink"
  c2
}

<<
  \new Staff \music
  \new Staff \music
>>
[image of music]

Sin embargo, se pueden resaltar varios pentagramas al mismo tiempo trasladando el grabador Staff_highlight_engraver a un contexto más elevado que Staff (o RhythmicStaff, o similar). Esto se hace usando las instrucciones \consists y \remove; See Modificar los complementos (plug-ins) de contexto para más información. Por ejemplo, si el grabador se traslada a Score, los resaltados se comparten por parte de todos los pentagramas.

\layout {
  \context {
    \Staff
    \remove Staff_highlight_engraver
  }
  \context {
    \Score
    \consists Staff_highlight_engraver
  }
}

music = {
  \time 2/4
  \staffHighlight "lightpink"
  c'4 4
  \staffHighlight "lightsteelblue"
  g'8( fis g4)-.
  \staffHighlight "lightpink"
  c2
}

<<
  \new Staff \music
  \new Staff \music
>>
[image of music]

También se puede trasladar el grabador Staff_highlight_engraver a contextos de nivel intermedio como StaffGroup.

music = {
  \time 2/4
  \staffHighlight "lightpink"
  c'4 4
  \staffHighlight "lightsteelblue"
  g'8( fis g4)-.
  \staffHighlight "lightpink"
  c2
}

<<
  \new StaffGroup \with { \consists Staff_highlight_engraver } <<
    \new Staff \with { \remove Staff_highlight_engraver } \music
    \new Staff \with { \remove Staff_highlight_engraver } \music
  >>
  \new Staff \music
>>
[image of music]

Se puede usar la propiedad StaffHighlight.shorten-pair para trucar el comienso y final horizontales del objeto de extensión del resaldado.

{
  c'1
  \once \override Staff.StaffHighlight.shorten-pair = #'(1.0 . 1.0)
  \staffHighlight lightsteelblue
  c'1
}
[image of music]

Instrucciones predefinidas

\staffHighlight, \stopStaffHighlight.

Véase también

Referencia de la notación: Colorear objetos, Modificar los complementos (plug-ins) de contexto.

Referencia de funcionamiento interno: StaffHighlight, staff-highlight-interface, Staff_highlight_engraver, StaffHighlightEvent, staff-highlight-event.

Advertencias y problemas conocidos

El comportamiento de los resaltados puede no ser el esperado en las barras de inicio de una repetición. Se puede usar la propiedad shorten-pair mostrada anteriormente para resolver el problema.

{
  \staffHighlight "lightsteelblue"
  c'1
  \stopStaffHighlight
  \repeat volta 2 { c'1 }
  c'1
}
[image of music]

Referencia de la notación de GNU LilyPond v2.25.30 (development-branch).