Le 19/01/2022 à 13:58, Thomas Scharkowski a écrit :

Am 19.01.2022 um 13:09 schrieb Jean Abou Samra <j...@abou-samra.fr>:

Le 19/01/2022 à 09:46, Thomas Scharkowski a écrit :
Hallo,

I’d like to replace the arpeggioBracket by a curly bracket / brace.
Thank your for your help!

Here's a stencil callback reading the vertical start
and end positions of the arpeggio and printing a bracket
accordingly:

\version "2.22.1"

arpeggioBrace =
\tweak stencil
   #(lambda (grob)
      (let* ((positions (ly:grob-property grob 'positions))
             (layout (ly:grob-layout grob))
             (scale (ly:output-def-lookup layout 'output-scale))
             (factor (/ scale (ly:pt 1)))
             (len (* factor (+ 0.5 (interval-length positions))))
             (brace-markup (make-left-brace-markup len))
             (brace-stencil (grob-interpret-markup grob brace-markup)))
        (ly:stencil-translate-axis brace-stencil
                                   (interval-center positions)
                                   Y)))
\arpeggio

\relative {
   \clef bass
   <e g b g'>\arpeggioBrace
}


Best,
Jean

Thank you Jean,

This is very nice!
How can I use this for connected arpeggios through voices?


These are a bit special because they are not created
from the \arpeggio events. Use \override rather than
\tweak in this case.

\version "2.22.1"

spanArpeggioBrace =
\once \override PianoStaff.Arpeggio.stencil =
  #(lambda (grob)
     (let* ((positions (ly:grob-property grob 'positions))
            (layout (ly:grob-layout grob))
            (scale (ly:output-def-lookup layout 'output-scale))
            (factor (/ scale (ly:pt 1)))
            (len (* factor (+ 0.5 (interval-length positions))))
            (brace-markup (make-left-brace-markup len))
            (brace-stencil (grob-interpret-markup grob brace-markup)))
       (ly:stencil-translate-axis brace-stencil
                                  (interval-center positions)
                                  Y)))

\new PianoStaff \with {
  connectArpeggios = ##t
}
<<
  \new Staff \relative {
    \spanArpeggioBrace
    % Looks better a bit closer to the notes?
    \once \override PianoStaff.Arpeggio.padding = 0.1
    % A bit of padding to the left?
    \once \override PianoStaff.Arpeggio.extra-spacing-width = #'(-1 . 0)
    g'\arpeggio
  }
  \new Staff \relative {
    \clef bass
    <e g b>\arpeggio
  }
>>

Best,
Jean


Reply via email to