3

I cannot get the accidental and beam in voice two to be blue (bars 7-8), and if I include the ledger line override in voice two, it overrides the command in voice one (the ledger lines are black rather than red).

 \repeat volta 2 { << { \voiceOne
\override Staff.LedgerLineSpanner #'color = #darkred
\override NoteHead.color = #darkred
\override Dots.color = #darkred
\override Stem.color = #darkred
\override Beam.color = #(x11-color "DarkRed")
\override Accidental.color = #(x11-color 'DarkRed)
 
b'4 c4. b8 | a4 b2 | d8 f, e4. e8 | c'8 g fis4 d | a'8 c, b4. g'8 |
 b8 d, cis4. a8 | g'8 cis d[ fis,] e d | \once \override NoteColumn.force-hshift = 1 a cis d2 | }

  \new Voice 
  { \voiceTwo
\override Staff.LedgerLineSpanner #'color = #darkblue
\override NoteHead.color = #darkblue
\override Dots.color = #blue
\override Accidental.color = #(x11-color 'darkblue)
\override Stem.color = #darkblue
\override Beam.color = #(x11-color 'darkblue) 

 g,4 g2 | fis4 g2 | b4 c2 | a8 g8 fis2 | fis4 g2 | g4 a2 |  cis4 fis,4 a4 | a4 d d, }>> 
   \oneVoice  } 
}

Here's the whole file. https://drive.google.com/file/d/1wBQTijOKhWw0LN6ZvhTk9AeNR0YKYuC_/view?usp=sharing

Output of above code

2

Thanks to @user72086 above this works. Their answer is the more concise as future reference.

\version "2.19.83"
\header {
  title = "J.S. Bach's G Major Sarabande"
  subtitle = ""
  composer = ""
}
colorNotes =
#(define-music-function
     (parser location myColor)
     (color?)
   #{
     \override LedgerLineSpanner.color = #myColor
     \override NoteHead.color = #myColor    
     \override Dots.color = #myColor  
     \override Stem.color = #myColor 
     \override Beam.color = #myColor   
     \override Accidental.color = #myColor
   #})

scoreAGlobal = {
  \key g \major
  \numericTimeSignature
  \time 3/4
}

scoreACelloI = \relative c {
  \scoreAGlobal 
  \repeat volta 2 { 
    << \new Voice \voiceOne {  
        \colorNotes #red
        b'4 c4. b8 | a4 b2 | d8 f, e4. e8 |
        c'8 g fis4 d | a'8 c, b4. g'8 |
        b8 d, cis4. a8 | g'8 cis d[ fis,] e d | 
        \once \override NoteColumn.force-hshift = 1 a cis d2 |   
       } \break
       \\
      \new Voice \voiceTwo { 
        \colorNotes #blue 
         g,4 g2 | fis4 g2 | b4 c2 |
         a8 g8 fis2 | fis4 g2 | g4 a2 |
         cis4 fis,4 a4 | a4 d d, |
      }
    >>
  }
}

scoreACelloIPart = \new Staff \with {
  instrumentName = "Simplified"
  midiInstrument = "cello"
}
{ \clef bass \scoreACelloI }

\score {
  << \scoreACelloIPart >>
  \layout {
   \context {
     \Staff
     \remove "Ledger_line_engraver"
  }
  \context {
     \Voice
     \consists "Ledger_line_engraver"
  }
}
  \midi {
    \tempo 4=100
  }
}
1
  • Yes, and thank you for laying it all out for me. I was not able to make it work until you did so. – Stephanie Sep 23 '20 at 14:56
2

Your code does not correspond to your output: different meter, different key, different clef. So there is no way I can "adjust" the code to get the desired result. Also because it has unmatched braces. Please make it a habit to actually test your examples.

The solution generally here would be to move the Ledger_line_engraver to Voice level and then override the Ledger_line color at Voice level (like you do with the other overrides) rather than at Staff level.

That would work by adding something akin to

\layout {
  \context {
     \Staff
     \remove "Ledger_line_engraver"
  }
  \context {
     \Voice
     \consists "Ledger_line_engraver"
  }
}

in front of your code. If you are lucky (I could not test it), it will work for your use case. Note that it may cause ledger lines to be drawn multiple times in which case the resulting color may be inconsistent.

2
  • Thank you for your help. I've included the entire fiile in the original message which does work. – Stephanie Sep 22 '20 at 19:55
  • @Stephanie do you have this working now or not? As I will post another answer with your code working. But user72086 is totally correct and I've used their code and your code together to get it to work. – user70304 Sep 23 '20 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.