lilypond-user
[Top][All Lists]
Advanced

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

Re: attach glissandi to stems instead of noteheads


From: Pierre Perol-Schneider
Subject: Re: attach glissandi to stems instead of noteheads
Date: Wed, 27 Jan 2016 20:02:12 +0100



2016-01-27 19:38 GMT+01:00 Caio Giovaneti de Barros <address@hidden>:

Well, you can see that this code is much bigger than mine.

Yep, plus some copy/paste errors. So here again:

\version "2.19.32"

#(define path-gliss
    (lambda (grob)
    (if (ly:stencil? (ly:line-spanner::print grob))
        (let* ((stencil (ly:line-spanner::print grob)))
          (ly:stencil-translate
            (grob-interpret-markup grob
              (markup
                (#: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)))))
       )))

#(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 (music)(ly:music?) (map-some-music add-gliss music))

equal-staff-stems =
%%% => http://lilypond.1069038.n5.nabble.com/Stem-length-at-a-fixed-height-td172661.html#a172686
#(define-music-function (val)(number?)
  #{
    \override Stem.direction =
      #(lambda (grob)
        (if (negative? val)
            DOWN
            UP))
    
    \override Stem.after-line-breaking =
      #(lambda (grob)
        (let* ((stem-begin-position (ly:grob-property grob 'stem-begin-position)))
          ;; the override for Beam.positions counts from staff-position 0
          ;; thus we need to go there for the (unbeamed) stem-length as well
        ;; beam-thickness is taken from engraver-init.ly:
        (ly:grob-set-property! grob
          'length
          (+ (if (negative? val)
                 stem-begin-position
                 (- stem-begin-position))
             (* (abs val) 2)
             ;; beam-thickness:
             0.32))))
    
    \override Beam.positions = #(cons val val)
  #})

%%% So, here it goes:
\score {
  \new Staff  \relative {
    \addGliss {
      e'8[ g b g e d' e,]
    }
  }
  \layout {
    \override NoteHead.transparent =##t
    \equal-staff-stems #6
    \override Stem.avoid-note-head =##t
    \override Glissando.minimum-length = #5
    \override Glissando.springs-and-rods = #ly:spanner::set-spacing-rods
    \override Glissando.thickness = #4
    \override Glissando.bound-details =#'(
       (right (attach-dir . 1) (padding . 0))
       (left  (attach-dir . 1) (padding . 0)))
    \override NoteHead.no-ledgers = ##t
    \stemUp
  }
}

Cheers,
Pierre

 
 


reply via email to

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