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 19:25:41 +0100

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))
        (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,]

}



On 27-01-2016 15:37, Caio Giovaneti de Barros wrote:
I'm trying to draw a suggestion for glissando in changing directions. The ideal notation would be beamed stems without note heads connected by glissandi. Here's what I got so far:

\version "2.19.35"


\relative c' {

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

\hide NoteHead

\override Glissando.thickness = #5

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

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

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

}

but is not looking very good... any suggestions?

Caio


_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user



reply via email to

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