lilypond-user
[Top][All Lists]
Advanced

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

Re: Pedals as Dynamics


From: Kieren MacMillan
Subject: Re: Pedals as Dynamics
Date: Mon, 16 Mar 2015 09:19:40 -0400

Hi Andrew,

> I’m using a Dynamics context for pedals. I would like to be able to replace 
> the vertical up bracket at the end of certain sustainOff events with an 
> arrowhead or other glyph or indeed some postscript. How could this be done? 
> What are pedal line markings exactly? Are they TextSpanners or 
> DynamicLineSpanners? While we are on the topic, where is the documentation 
> about how to change text at the right and left of TextSpanners? This sort of 
> thing: \once \override TextSpanner #'(bound-details right text) = \markup { 
> "foo” }

Here are two functions I use, which should point you in the right direction.

Hope this helps!
Kieren.
______________________

sustainHalf =
  \override SustainPedal #'stencil =
    #(lambda (grob)
      (grob-interpret-markup grob
        (markup #:raise 0.1 "½" #:hspace -1 #:musicglyph "pedal.Ped")))

pedalSim =
\once \override 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 #:hspace 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
       )))

_______________________

Kieren MacMillan, composer
www:  <http://www.kierenmacmillan.info>
email:  address@hidden




reply via email to

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