lilypond

stretch octava mark to end of measure


When a note has an octava mark, the end of the mark is at the end of the note. For long notes the visual effect is not satisfying. I would like to end the octava mark at the end of the measure.

This example shows what I mean:

\score {
    \new PianoStaff
    <<  
        \new Staff {
            \relative c'' {
                \clef treble \time 3/4
                a4 b c | d8 c b4 a | g2.
            }
        }
        \new Staff {
            \relative c {
                \clef bass \time 3/4
                a2.
                \ottava #2
                \set Staff.ottavation = #"15"
                b''2.
                \ottava #0
                c,,2.
            }
        }
    >>
}

This is the result This is the result

I would rather have this enter image description here

In order to accomplish that result, I added an extra voice with hidden notes, rendering the wanted result. The hidden voice forces the end of the octava mark to the end of the third note. My question is: is there a better/simpler way to obtain the same result?

This is the version with the 'hidden voice'

\score {
    \new PianoStaff
    <<  
        \new Staff {
            \relative c'' {
                \clef treble \time 3/4
                a4 b c | d8 c b4 a | g2.
            }
        }
        \new Staff {
            \relative c {
                \clef bass \time 3/4
                a2.
                \ottava #2
                \set Staff.ottavation = #"15"
                <<
                \new Voice { \voiceOne b''2. }
                \new Voice { \voiceTwo  \hideNotes a4 b c  \unHideNotes }
                >>
                \ottava #0
                c,,2.
            }
        }
    >>
}

Solution

  • There's no easy / nice way to do this. See OttavaBracket right endpoint?
    The code I got from there was:

    \once \override Staff.OttavaBracket.shorten-pair = #'(-1 . -9.5)
    

    where in the pair affect the start and end points of the bracket.

     \score {
        \new PianoStaff
        <<  
            \new Staff {
                \relative c'' {
                    \clef treble \time 3/4
                    a4 b c | d8 c b4 a | g2.
                }
            }
            \new Staff {
                \relative c {
                    \clef bass \time 3/4
                    a2.
                    \ottava #2
                    \set Staff.ottavation = #"15"
                    \once \override Staff.OttavaBracket.shorten-pair = #'(-1 . -9.5)
                    b''2.
                    \ottava #0
                    c,,2.
                }
            }
        >>
    }
    

    Update:
    I think modifying your original answer on hiding notes seems the best answer to me.
    Putting b as 1/3 of value and hiding and unhiding notes works:
    b''2.*1/3 \hideNotes b b \unHideNotes.
    Shorter code than:
    \once \override Staff.OttavaBracket.shorten-pair = #'(-1 . -9.5), and the automatic behaviour that we all want.

    \score {
        \new PianoStaff
        <<  
            \new Staff {
                \relative c'' {
                    \clef treble \time 3/4
                    a4 b c | d8 c b4 a | g2.
                }
            }
            \new Staff {
                \relative c {
                    \clef bass \time 3/4
                    a2.
                    \ottava #2
                    \set Staff.ottavation = #"15"
                    b''2.*1/3 \hideNotes b b \unHideNotes % works
                    % b''2.*1/3 s s % doesn't work
                    \ottava #0
                    c,,2.
                }
            }
        >>
    }