lilypond-user
[Top][All Lists]
Advanced

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

Re: override stencil question


From: David Nalesnik
Subject: Re: override stencil question
Date: Sun, 10 Mar 2013 22:50:26 -0500

Hi Rama,

On Sun, Mar 10, 2013 at 8:33 PM, Rama Gottfried <address@hidden> wrote:
Hi guys,

I'm making progress, but now am stuck and wondering if you have any advice or see anything I'm doing wrong here (code below).

What I would like to be able to do is specify the handle coordinates for the curve for each glissando.
The problem I'm having is that it seems that all glissandos are using the last value for the arc.

To try to fix the problem I added a call within the stencil callback function to get the current value of arc, but this isn't working.

Any ideas?

The problem here is the use of a top-level variable for the handle coordinates.  You could fix this by adding an argument to your stencil function.  I just took a quick look, but I think this will get you on the right track:

\version "2.17.13"

glissWidth = #0.2 %<< global variable for glissando width

#(define (path-gliss handle)
  (lambda (grob)
    (if (ly:stencil? (ly:line-spanner::print grob))
(let* ((stencil (ly:line-spanner::print grob))
      (X-ext (ly:stencil-extent stencil X))
      (Y-ext (ly:stencil-extent stencil Y))
      (width (interval-length X-ext))
      (height (interval-length Y-ext))
      (lefty (cdr (assoc 'Y (ly:grob-property grob 'left-bound-info))))
      (righty (cdr (assoc 'Y (ly:grob-property grob 'right-bound-info))))
      (deltay (- righty lefty))
      (dir (if (> deltay 0) 1 -1)))

  (ly:stencil-translate
    (grob-interpret-markup grob
      (markup
    ;(#: tiny (format "~a" (ly:grob-properties grob)))
    ;(format "~a" (cdr (assoc 'Y (ly:grob-property grob 'left-bound-info))))
    ;(#: tiny (format "~a" handle))
(#:path glissWidth
  (list (list 'moveto 0 0)
(list 'curveto 0 0 (first handle) (second handle) width (* height dir))))))
    (if (> dir 0)
   (cons (interval-start X-ext) (+ (interval-start Y-ext) 0.1))
   (cons (interval-start X-ext) (+ (interval-start Y-ext) height)))))
 #f)))


#(define (add-gliss m)
   (case (ly:music-property m 'name)
     ((NoteEvent) (set! (ly:music-property m 'articulations)
                      (append (ly:music-property m 'articulations)
                         (list (make-music (quote GlissandoEvent)))))
                   m)
     (else #f)))

addGliss = #(define-music-function (parser location music)
                 (ly:music?)
           (map-some-music add-gliss music))

\new Staff \with {
        \remove "Time_signature_engraver"
        \remove "Clef_engraver"
        \omit Staff.BarLine
         \override SpacingSpanner
                #'base-shortest-duration = #(ly:make-moment 1 32)

        \override StaffSymbol #'line-count = #1
        \override Stem #'direction = #UP
        \override NoteHead #'transparent = ##t
        \override NoteHead #'no-ledgers = ##t
        \override NoteHead #'stem-attachment = #'(0 . 0)
        \override Glissando #'bound-details = #'((right (attach-dir . 0) (end-on-accidental . #f) (padding . 0.)) (left (attach-dir . 0) (padding . 0.)))
}
\relative b' {
        \addGliss {
                \once \override Glissando #'stencil = #(path-gliss '(2 4))
                c8
                \once \override Glissando #'stencil = #(path-gliss '(3 -4))
                d
               \once \override Glissando #'stencil = #(path-gliss '(2 4))
                a
                b }
                f
         \addGliss{
                d'16
                a
                c2 }
                b32
}


HTH,
David

reply via email to

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