lilypond-user
[Top][All Lists]
Advanced

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

Re: How to tweak/override the individual Glissando objects in a chord?


From: Thomas Morley
Subject: Re: How to tweak/override the individual Glissando objects in a chord?
Date: Wed, 21 Aug 2013 12:07:54 +0200

2013/8/21 Janek Warchoł <address@hidden>:
> Hi,
>
> 2013/8/21 Dominic <address@hidden>:
>> Hello all, sorry for the frequent posting
>
> No problem!  I've noticed that you write excellent descriptive email
> subjects - that's very good (and that's why i looked at this email) :)
>
>> Here is a small example:
>> /\relative c' { <a'' b c>1 \glissando <c, d e>1 }/
>>
>> If I wanted to modify those glissando lines (e.g. move one of them slightly
>> lower), how would I go about doing that without affecting the other two?
>
> Unfortunately there is no "user-level" syntax for this - you have to
> write a Scheme function that will hook into formatting process.
> Fortunately, i found an example (in Lily's regression tests
> http://www.lilypond.org/doc/v2.17/input/regression/collated-files.html)
> and was easy to modify it to do what you want:
>
> \relative c' {
>   \once \override Voice.Glissando.extra-offset =
>     #(lambda (grob)
>        (if (= 1 (ly:grob-property grob 'glissando-index)) '(0.8 . 0.3)
> '(0 . 0)))
>   <a'' b c>1 \glissando <c, d e>1
> }
>
> best,
> Janek



Hi Dominic,

below a more elaborated function I made some time ago (version
2.15.39), still working up to 2.17.24.
It uses 'glissando-index like the regtest Janek mentioned already.
Using 2.17.24 you'll see a padding/collision-issue even with the
untweaked glissando.
Probably a bug.

\version "2.15.39"

#(define (radians->degree radians)
  (/ (* radians 180) PI))

#(define ((gliss-plus-text padding text) grob)
  (let* ((text-stencil (grob-interpret-markup grob text))
         (spanner-stencil (ly:line-spanner::print grob))
         (left-bound-info (ly:grob-property grob 'left-bound-info))
         (y-left (cdar left-bound-info))
         (right-bound-info (ly:grob-property grob 'right-bound-info))
         (y-right (cdar right-bound-info))
         (slant (if (> y-right y-left) 1 -1))
         (spanner-stencil-x-length
            (interval-length (ly:stencil-extent spanner-stencil X)))
         (spanner-stencil-y-length
            (interval-length (ly:stencil-extent spanner-stencil Y)))
         (alpha
            (radians->degree
              (atan (/ spanner-stencil-y-length spanner-stencil-x-length))))
         (spanner-center-X
            (interval-center (ly:stencil-extent spanner-stencil X)))
         (label-center-X (interval-center (ly:stencil-extent text-stencil X))))
  (ly:stencil-combine-at-edge
    spanner-stencil
    Y UP
    (ly:stencil-translate
      (ly:stencil-rotate text-stencil (* slant alpha) 0 0)
      (cons (- spanner-center-X label-center-X) 0))
    (+ (* -0.5 spanner-stencil-y-length) padding))))

glissTweak =
#(define-music-function (parser location lst)(pair?)
#{
       \once \override Glissando #'after-line-breaking =
          #(lambda (grob)
            (let ((gliss-count (ly:grob-property grob 'glissando-index)))
            (map (lambda (x)
              (let ((gliss-nmbr (car x))
                    (property-value-alist (cdr x)))
                (if (eq? gliss-nmbr gliss-count)
                  (map
                    (lambda (y) (ly:grob-set-property! grob (car y) (cdr y)))
                    property-value-alist)
                  #f)))
;             $lst))) % for Version "2.14.2"
              lst)))
       $(make-music 'EventChord 'elements (list (make-music 'GlissandoEvent)))
#})

tweakedGliss = {
        \once \override Glissando #'minimum-length = #8
        \once \override Glissando #'springs-and-rods =
          #ly:spanner::set-spacing-rods
}

\relative c' {
        \override TextScript #'font-size = #-2

        <c e g bes d>2\glissando^"\"no tweaks\""
        <d, a' fis' c' e'>

        \tweakedGliss
        \glissTweak
          #`((0 . ((color . ,red)
                   (normalized-endpoints . (0 . 0.8))
                   (stencil . ,(gliss-plus-text -1.8
                                 (markup #:italic #:fontsize -8 "gliss.")))))
             (1 . ((style . zigzag)))
             (2 . ((style . trill)
                   (color . (0.5 0.5 0.5))))
             (3 . ((style . dashed-line)))
             (4 . ((stencil . ,(gliss-plus-text 0
                                 (markup #:italic #:fontsize -8 "gliss.")))
                   (normalized-endpoints . (0 . 0.7))
                   (color . ,green))))
        <c' e g bes d>2^"\"some tweaks\""
        <d, a' fis' c' e'>

        \once \override Glissando #'(bound-details right arrow) = ##t
        \glissTweak
          #`((0 . ((style . dashed-line)
                   (normalized-endpoints . (0 . -2.1))))
             (1 . ((stencil . #f)))
             (2 . ((stencil . #f)))
             (3 . ((stencil . #f)))
             (4 . ((style . dashed-line)
                   (normalized-endpoints . (0 . -1.5)))))
        <c' e g bes d>2^"\"some other tweaks\""
        <d, a' fis' c' e'>

}


Please note: I merely copied and pasted it from an old file and did no
revision so far, if you encounter any problem, please shout.
Attached image was created with 2.15.39

HTH,
  Harm

Attachment: gliss-chf-2.png
Description: PNG image


reply via email to

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