lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: color change working in only upper staff


From: Pierre Perol-Schneider
Subject: Re: color change working in only upper staff
Date: Mon, 18 Jul 2022 17:22:26 +0200

Hi William, hi Jim,

Le lun. 18 juil. 2022 à 16:38, William Rehwinkel <william@williamrehwinkel.net> a écrit :

Hey Jim,

To be honest, I'm not sure why the example you posted doesn't work, but I was able to find a workaround by using \contexts to apply the override to each staff, like so.

Using << { } // { } >> creates additional voices, so that pevious oveerides  cannot apply

\version "2.20.0"

upper = \relative c'' { % remove \override
  \clef treble
  \key c \major
  \time 4/4

a-1 cis' <e, a c e>\tuplet 3/2 {<c c'>8~<c c'> <c c'>}


}

lower = \relative c { % remove \override
  \clef bass
  \key c \major
  \time 4/4

<<{f'1}-2\\{r4. e32-1 cis-2 a-4 f-1 d2-2}>>

}

\score {
  \new PianoStaff <<
    \set PianoStaff.instrumentName = #"Piano  "
    \new Staff = "upper" \upper
    \new Staff = "lower" \lower
  >>
  \layout {
    \context {
        \Staff
        \override Fingering.color = #red
    }
  }
  \midi { }
}

Staff context is not needed here (see https://lilypond.org/doc/v2.20/Documentation/internals/fingering_005fengraver)

Here's a modified code with few shorcuts:

\version "2.20"

upper = \relative { %% <= c'' not needed
  %\override Fingering.color = #red
  %\clef treble %% <= default clef, not needed
  \key c \major
  %\time 4/4 %% <= default time signature, not needed
  a'-1 cis' <e, a c e> \tuplet 3/2 { <c c'>8~ q q } %% <= shorter chords
}

lower = \relative { %% <= c not needed
  %\override Fingering.color = #red
  \clef bass
  \key c \major
  %\time 4/4 %% <= default time signature, not needed
  << { f'1-2 } \\ { r4. e32-1 cis-2 a-4 f-1 d2-2 } >>
}

\score {
  \new PianoStaff <<
    %\set PianoStaff.instrumentName = #"Piano  " %% <= see hereunder
    \new Staff = "upper" \upper
    \new Staff = "lower" \lower
  >>
  \layout {
    \context {
        \Voice
        \override Fingering.color = #red
    }
    \context {
        \PianoStaff
        instrumentName = #"Piano"
        \override InstrumentName.padding = #2 %% <= more accurate than spaces
    }
  }
  \midi { }
}

Cheers,
Pierre

reply via email to

[Prev in Thread] Current Thread [Next in Thread]