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: Caio Giovaneti de Barros
Subject: Re: attach glissandi to stems instead of noteheads
Date: Wed, 27 Jan 2016 16:38:58 -0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

Well, you can see that this code is much bigger than mine. I'm a bit uncomfortable because I don't have yet the lilypond-scheme vocabulary to understand it.

OTOH, it has a more convenient syntax, not needing to add a \glissando in every note. It should be a good solution for longer passages. I'm saving it for future use ;)

On 27-01-2016 16:25, Pierre Perol-Schneider wrote:
Hi Caio,

How about:

\version "2.19.35"

#(define path-gliss
    (lambda (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))e
        (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)))))
       ))))

#(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


2016-01-27 19:12 GMT+01:00 Caio Giovaneti de Barros <address@hidden>:
I think I got it. It's a bit of an ugly code, but works.

\version "2.19.35"


\relative c' {

\override NoteHead.stencil = #ly:text-interface::print

\override NoteHead.text = \markup { \null }

\override NoteHead.stem-attachment = #'(0 . 0)

\override Glissando.thickness = #5

\override Glissando.bound-details.left.padding = #0

\override Glissando.bound-details.right.padding = #0

e8[\glissando g\glissando b\glissando g\glissando e\glissando d'\glissando e,]

}


reply via email to

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