1

I continue my struggle (began here) with engraving Barrozo's collection of Czerny exercises. The problem is in engraving brackets that Barrozo uses to mark parts for repetition. Following advice of Lazy, I used a multimark engraver. I don't understand this code and thus don't know how to change the stack order of the marks. Here is my result: enter image description here

I want the two brackets between the 6-th and the 7-th bars to be below the octave bracket. How can I do it? I tried changing outside-staff-priority, but it didn't help. Maybe script-priority can help? But where should I put it?

Here is the full code (sorry, a lot of text)

\version "2.22.1"
\language "italiano"

openBracket =
    \tweak self-alignment-X #'()
    \tweak break-visibility #end-of-line-invisible
    \mark \markup {
        \path #0.2 #'((moveto 0 0) (lineto 0 2) (lineto 1.3 2))
    }
closeBracket =
    \tweak self-alignment-X #'()
    \tweak break-visibility #begin-of-line-invisible
    \mark \markup {
        \path #0.2 #'((moveto 0 0) (lineto 0 2) (lineto -1.3 2))
    }
doubleBracket =
    \tweak self-alignment-X #'()
    \mark \markup {
        \path #0.2 #'((moveto -0.2 0) (lineto -0.2 2) (lineto -1.5 2)
                      (moveto  0.2 0) (lineto  0.2 2) (lineto  1.5 2))
    }

#(set-global-staff-size 18)

\layout {
    \context {
        \Score
        \omit BarNumber
    }
}

leggermente = #(make-dynamic-script
               (markup #:normal-text #:italic "leggermente"))

#(define (multi-mark-engraver ctx)
    (let
        ((texts '())
         (final-texts '())
         (events '()))

      `(
            (start-translation-timestep
                . ,(lambda (trans)
                (set! final-texts '())))

            (listeners
                (mark-event
                    . ,(lambda (trans ev)
                    (set! events (cons ev events)))))

            (acknowledgers
                (break-alignment-interface
                    . ,(lambda (trans grob source)
                        (for-each
                            (lambda (mark)
                                (set! (ly:grob-parent mark X) grob))
                            texts))))

            (process-music
                . ,(lambda (trans)
                    (for-each
                        (lambda (ev)
                            (let*
                                (
                                    (mark-grob (ly:engraver-make-grob trans 'RehearsalMark ev))
                                    (label (ly:event-property ev 'label))
                                    (formatter (ly:context-property ctx 'markFormatter))
                                )

                                (if
                                    (and (procedure? formatter) (not (markup? label)))
                                    (begin
                                        (if (not (number? label))
                                            (set! label
                                                (ly:context-property ctx 'rehearsalMark)))

                                        (if (and (integer? label)
                                            (exact? label))
                                            (set!
                                                (ly:context-property ctx 'rehearsalMark)
                                                (1+ label)))

                                        (if (number? label)
                                            (set! label (apply formatter (list label ctx)))
                                            (ly:warning "rehearsalMark must have integer value"))))

                                (if (markup? label)
                                    (begin
                                        (set! (ly:grob-property mark-grob 'text) label)
                                        (let ((dir (ly:event-property ev 'direction)))
                                            (and (ly:dir? dir)
                                                (set! (ly:grob-property mark-grob 'direction) dir))))
                                    (ly:warning "mark label must be a markup object"))

                                (set! texts (cons mark-grob texts))))
                        (reverse events))))

            (stop-translation-timestep
                . ,(lambda (trans)
                    (if (pair? texts)
                        (let
                            ((staves (ly:context-property ctx 'stavesFound)) (priority-index 0))
                            (for-each
                                (lambda (grob)
                                    (let
                                        ((my-priority (ly:grob-property grob 'outside-staff-priority 1500)))
                                        (for-each (lambda (stave) (ly:pointer-group-interface::add-grob grob 'side-support-elements stave)) staves)
                                        (set! (ly:grob-property grob 'outside-staff-priority) (+ my-priority priority-index))
                                        (set! priority-index (1+ priority-index))
                                        (set! final-texts (cons grob final-texts))))
                                (reverse texts))
                            (set! texts '())
                            (set! events '())))))

            (finalize
                . ,(lambda (trans)
                    (and
                        (pair? final-texts)
                        (for-each
                            (lambda (grob)
                                (set! (ly:grob-property grob 'break-visibility) end-of-line-visible))
                            final-texts)))))))

\score {
    \header {
        opus = "Op. 261 №7"
    }
    \new PianoStaff \with {
        instrumentName = "11."
        \override InstrumentName.font-size = #6
        \override InstrumentName.self-alignment-X = #RIGHT
    } <<
        \new Staff = "правая" \with {}
        \relative do' {
            \key do \major
            \time 2/4
            \tempo "Allegretto vivace"
            \set Timing.baseMoment = #(ly:make-moment 1/32)
            \set Timing.beatStructure = 4, 4, 4, 4
            \openBracket
            do'32-3 (_[sol-1 re'-4 sol,-1]) mi'16-!-5 \noBeam r16 mi32-3 (_[do-1 fa-4 do-1]) sol'16-!-5 \noBeam r16 |
            do,32-3 (_[sol-1 re'-4 sol,-1]) mi'16-!-5 \noBeam r16 mi32-3 (_[do-1 fa-4 do-1]) sol'16-!-5 \noBeam r16 |
            fa32-4 (_[sol-5 mi-3 sol-5]) re16-!-2 \noBeam r16 mi32-3 (_[sol-5 re-2 sol-5]) do,16-!-1 \noBeam r16 |
            \once \override Fingering.avoid-slur = #'inside
            re32-2 (sol-5 re-2 sol-5 si,-1 re-4 si-2 re-4) sol,16-!-1 [sol-!-3 sol-!-2 sol-!-1] \closeBracket |
            \openBracket
            do32-3 (_[sol-1 re'-4 sol,-1]) mi'16-!-5 \noBeam r16 mi32-3 (_[do fa-4 do]) sol'16-!-5 \noBeam r16 |
            \ottava #1 do32-3 (_[sol re'-4 sol,]) mi'16-!-5 \noBeam r16 mi32-3 (_[do fa-4 do]) sol'16-!-5 \noBeam r16 |
            \doubleBracket
            la32-5 (la,-1 la'-5 sol fa-3 mi re-1 do-4 \ottava #0 si-3 la sol-1 fa-4 mi-3 re do-1 si-2 |
            do-1 re mi-3 fa-1 sol-2 la si do-5 do,16-.-1) r r8 \closeBracket
            \bar "|."
        }
        \new Dynamics {
            s16 \p
            \once \override DynamicText.X-offset = 0
            s32 \leggermente s32 s8 s4 | s2 | s2 |
            s32 \> s32 s32 s32 s32 s32 s32 s32 s16 s16 s16 s16 \! |
            s32 \p s32 s32 s32 s16 s16 s32 s32 s32 s32 s16 s16 |
            s32 \mf s32 s32 s32 s16 s16 s32 s32 s32 s32 s16 s16 |
            s32 \f s32 s32 s32 s32 s32 s32 s32 s32 s32 s32 s32 s32 s32 s32 s32 |
        }
        \new Staff = "левая" \with {}
        \relative do {
            \clef bass
            \set fingeringOrientations = #'(down)
            <do-4>16-. _[r <mi-2 sol-1>-.] r do-. _[r <mi sol>-.] r |
            <do-4>-. _[r <mi-2 sol-1>-.] r do-. _[r <mi sol>-.] r |
            <do-5>-. _[r <re-3 sol-1>-.] r <do-4>-. _[r <mi-2 sol-1>-.] r |
            <sol-3 si-1>8-> r8 r4 |
            <do,-4>16-. _[r <mi-2 sol-1>-.] r do-. _[r <mi sol>-.] r |
            <do-4>-. _[r <mi-2 sol-1>-.] r do-. _[r <mi sol>-.] r |
            <fa-5 la-3 re-1>8 r <sol-5 re'-2 fa-1> r |
            <do-3 mi-1>16-. r <do mi>-. r <do mi>-. r r8
        }
    >>
    \layout {
        \context {
            \Score
            \override SpacingSpanner.spacing-increment = 1.1
            \remove "Mark_engraver"
            \consists #multi-mark-engraver
            \consists "Tweak_engraver"
        }
    }
}

1 Answer 1

4

Try

\tweak outside-staff-priority #100 \doubleBracket

At least on my end this works. Note that the priority needs to be lower than the Priority of the OttavaBracket, which defaults to 400.

5
  • Thanks! Is there any way to know when I should use \override or \tweak?
    – facetus
    May 10, 2022 at 4:34
  • 2
    @facetus \override sets the default values of a grob for a context. Thus it affects any grob starting at the timeframe this was set. \tweak on the other hand sets a property of the music event and thus only affects this single music events. This means that you should use \override if you want to affect all occurrences, while \tweak can be used to change a single entity. In some cases you could use \once\override for this, but this will still affect all grobs in the same timeframe.
    – Lazy
    May 10, 2022 at 13:47
  • 1
    @facetus For example this \new Voice << c' {\once\override NoteHead.font-size = -2 e'} g' >> does not work (as the override affects all heads), but this \new Voice << c' \tweak font-size -2 e' g' >> does. Of course in your case you can also do \once\override Score.RehearsalMark.outside-staff-priority = #100 \doubleBracket. as you do not have multiple Marks at the same time. But it is longer and somewhat depnding on \doubleBracket using Marks when it could also use markups or whatever.
    – Lazy
    May 10, 2022 at 13:51
  • There is a line in the multimark engraver that sets outside-staff-priority. Why changing it in the multimark engraver code doesn't change the stack order?
    – facetus
    May 12, 2022 at 15:16
  • @facetus The line in question is (set! (ly:grob-property grob 'outside-staff-priority) (+ my-priority priority-index)). Changing this will change the stackorder, but you should not do this! This part simply adds a little bit to the outside staff priority so that the different marks have different priorities.
    – Lazy
    May 12, 2022 at 22:11

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.