2013/6/14 Thomas Morley <[email protected]>

>
>
> 2013/6/14 Kieren MacMillan <[email protected]>
>
>> Hi Harm,
>>
>> it's not completely clear to me what you want to achieve.
>>
>>
>> I want this:
>>
>> 1. Best Option = adjust the stencil of the bracket so that \sustainOff
>> would print the entire grouping  "/\_  sim."
>>
>>
>> Please look at the output from the code below and tell what's good/wrong.
>>
>>
>> The "sim." is in the wrong place, and there should be an up and down and
>> small horizontal line right before it (as if the pedal bracket was
>> continuing). Here's a (horrible) example:
>>
>>
>>
>> Thanks!
>> Kieren.
>>
>
> Hi Kieran,
>
> thanks for the image. I think I understand now, will try this evening.
>
> -Harm
>

Hi Kieran,

please try the code below (same attached).
Note that the \pedalSim has to be inserted before the PianoPedalBracket
starts.
Behaviour at line-break is supported, though not widely tested.
Several comments in code.

\version "2.17.20"

\paper {
    ragged-right = ##t
    %% To watch the behaviour at line-break uncomment next line.
    %line-width = 80
}

pedalSim =
\once \override Staff.PianoPedalBracket #'stencil =
  #(lambda (grob)
   (let* (;; have we been split?
         (orig (ly:grob-original grob))
         ;; if yes, get the split pieces (our siblings)
         (siblings (if (ly:grob? orig)
                       (ly:spanner-broken-into orig)
                       '())))
   ;; Modify the unbroken grob-stencil or the first part of the broken
   ;; grob-stencil.
   (if (or (null? siblings)
           (and (>= (length siblings) 2)
                (eq? (car siblings) grob)))
       (let* (;; Get the default-stencil and its x-dimension and x-length.
              (stil (ly:piano-pedal-bracket::print grob))
              (stil-x-extent (ly:stencil-extent stil X))
              (stil-x-length (interval-length stil-x-extent))
              ;; Create a stencil to be added to the default-stencil.
              ;; Gets its x-dimension and x-length.
              (sim-stil
                 (grob-interpret-markup grob
                    (markup #:fontsize -1 #:italic "sim.")))
              (sim-stil-x-extent (ly:stencil-extent sim-stil X))
              (sim-stil-x-length (interval-length sim-stil-x-extent))
              (thickness (max (layout-line-thickness grob) 0.1))
              ;; The value to shorten the default-stencil from the right
side.
              ;; 0.8 will shorten about 80%.
              ;; Hard-coded, could be turned into a music-function.
              (amount 0.8))

         ;; Print a warning if the length of the default-stencil would not
         ;; warrant a sufficient output.
         (if (> sim-stil-x-length stil-x-length)
             (ly:warning "PianoPedalBracket is too short"))

         ;; Shorten the default-stencil.
         (ly:grob-set-property!
            grob
            'shorten-pair
            (cons 0 (* amount stil-x-length)))

         ;; Calculate the final stencil.
         (let* (;; Get the shortened (default-)stencil
                ;; and its y-dimension.
                (shortened-stil (ly:piano-pedal-bracket::print grob))
                (shortened-stil-y-ext (ly:stencil-extent shortened-stil Y))
                ;; Modify the sim-stil to gain a little gap to the left and
                ;; enlarge it downwards a little (otherwise the
stencil-whiteout
                ;; will not work sufficient.
                (new-sim-stil
                  (ly:make-stencil
                    (ly:stencil-expr sim-stil)
                    (interval-widen sim-stil-x-extent (* 2 thickness))
                    (cons (- (car shortened-stil-y-ext) thickness)
                          (cdr shortened-stil-y-ext)))))

           (ly:stencil-add
               shortened-stil
               (ly:stencil-translate-axis
                  (stencil-whiteout new-sim-stil)
                  (* (- 1 amount) (- stil-x-length sim-stil-x-length))
                  X))))
       ;; TODO:
       ;; Is there any need to return #f explicitly?
       ;; Deleting it seems to make no difference.
       ;#f
       )))

\relative c' {
    \set Staff.pedalSustainStyle = #'bracket
    c4\sustainOn a e' f
    \pedalSim
    c\sustainOff\sustainOn a e' f'
    c4\sustainOff a e' f
}


Please shout if something is wrong.


HTH,
  Harm

<<Screen Shot 2013-06-13 at 20.59.33.png>>

Attachment: pedal-sim-02.ly
Description: Binary data

<<attachment: pedal-sim-02.png>>

_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to