lilypond-user
[Top][All Lists]
Advanced

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

RE: Pedal cautionary continuations and other bracket decorations


From: Andrew Bernard
Subject: RE: Pedal cautionary continuations and other bracket decorations
Date: Sat, 12 Nov 2016 14:19:44 +1100

Well. Despite what I said about after line breaking, that must have been the case with an earlier version of the code. Changing my code to use after line breaking, thus:

 

pedalWithArrowsAndText =

\override Score.PianoPedalBracket.after-line-breaking =

#(lambda (grob)

 

works fine.

 

But a second issue arises. After a sustainOff followed by a sustainOn on a note, the pedal bracket left hand side text decoration is repeated at that point. So that’s probably a more interesting issue that still needs figuring out.

 

I’m pasting the updated code here to make it easy to just compile.

 

Andrew

 

== snip

 

\version "2.19.50"

 

\include "scheme.ily"

#(use-modules (srfi srfi-1))

 

#(define (make-arrow-path arrow-length arrowhead-height arrowhead-width)

   "Arrow with triangular arrowhead."

   (list

    'moveto 0 0

    'lineto arrow-length 0

    'lineto arrow-length (/ arrowhead-width 2)

    'lineto (+ arrow-length arrowhead-height) 0

    'lineto arrow-length (- (/ arrowhead-width 2))

    'lineto arrow-length 0

    'closepath

    ))

 

pedalWithArrowsAndText =

\override Score.PianoPedalBracket.after-line-breaking =

#(lambda (grob)

 

   ;; function to modify the individual grob part

   (define add-decorations

     (lambda (g list-length)

       (let* (

               ;; unpack the argument

               (index (car g))

               (grobber (cadr g))

               (last (= index list-length))

 

               ;; Get the default-stencil and its x-dimension and x-length.

               (stil (ly:piano-pedal-bracket::print grobber))

               (stil-x-extent (ly:stencil-extent stil X))

               (stil-x-length (interval-length stil-x-extent))

 

 

               ;; make arrow for the rhs end

               (thickness 0.1)

               (arrowhead-height 1.0)

               (arrowhead-width 1.0)

               (arrow-length 1.0)

               (arrow (make-path-stencil (make-arrow-path arrow-length arrowhead-height arrowhead-width) thickness 1 1 #t))

               (new-stil (if (not last)

                             (ly:stencil-combine-at-edge stil X RIGHT arrow -2)

                             stil))

 

               ;; make text for the lhs end

               (text-stil

                (grob-interpret-markup grobber

                  (markup

                   #:line

                   (#:abs-fontsize

                    6

                    (#:sans

                     (#:upright

                      (#:whiteout (#:box (#:pad-markup 0.3 "½ ped")))))))))

 

               (new-stil (ly:stencil-stack new-stil X LEFT text-stil -6)))

 

         (dbg index)

         (dbg (ly:grob-basic-properties grobber))

         (sep)

         (dbg (ly:grob-properties grobber))

         (sep) (sep)

 

         (ly:grob-set-property! grobber 'stencil new-stil))))

 

   (let* (

           (stil (ly:piano-pedal-bracket::print grob))

           (orig (ly:grob-original grob))

           (pieces (if (ly:grob? orig)

                       (ly:spanner-broken-into orig)

                       '()))

           (pieces-indexed-list (zip (iota (length pieces) 1) pieces))

           (pieces-length (length pieces)))

 

     ;; We want arrows on all segments but the last, and text on all segments, so

     ;; we have to pass some notion of list index to the function doing the

     ;; decorating. Hence the ziplist combining grob segment and index in pairs.

 

     (let loop ((x 1)

                (count 0))

       (if (< count pieces-length)

           (begin

            (add-decorations (list-ref pieces-indexed-list count) pieces-length)

            (loop x (+ count 1))

            )))

 

     stil))

 

%===========================================================================================

 

treble = {

  \clef treble

  \time 4/4

  c'4 c' c' c'

  c' c' c' c'

}

 

bass = {

  \clef bass

  \time 4/4

 

  c4

  \pedalWithArrowsAndText

  c\sustainOn c c

  c c c c

  \break

  c c c c

  \break

  c c c^\sustainOff\sustainOn c

  \break

  c c c c

  \break

  c c c c

  \break

  c c c c\sustainOff

 

}

 

\score {

 

  \new PianoStaff

  <<

    \new Staff = "treble"  { \treble }

    \new Staff = "bass" { \bass }

  >>

 

  \layout {

    \context {

      \Score

      pedalSustainStyle = #'bracket

    }

  }

}

== snip

 


reply via email to

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