lilypond-user
[Top][All Lists]
Advanced

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

Re: Get default Gliss endpoint Y value and add intelligently a value on


From: Aaron Hill
Subject: Re: Get default Gliss endpoint Y value and add intelligently a value on top of it
Date: Fri, 19 Mar 2021 20:33:45 -0700
User-agent: Roundcube Webmail/1.4.9

On 2021-03-19 12:30 pm, Dimitris Marinakis wrote:
I don't like manually setting Y values of glissando endpoints. I'd
appreciate a more thoughtful approach.
Is it possible to reference the calculation Lilypond already does and add a
value to it without trying to guesstimate what the actual value is from
scratch? The default placement is sometimes 95% fine but I'd like to nudge
it a bit upwards or downwards without tweaking the padding.

This makes cross-staff glissando editing really annoying. If my thinking makes sense, this would solve the problem partially since Lilypond will do its best each time the staff spacing gets changed but the tweak will help
on top of that.

Normally, this would be a job for \offset. However, \offset does not work with all properties, in particular, nested properties like the bound-details of the line-spanner-interface.

But you can effect the same change by using extra-dy and Y-offset with a little bit of arithmetic:

%%%%
\version "2.22.0"

offsetGlissando =
#(begin
  (define (number-or-number-list? arg)
   (or (number? arg) (number-list? arg)))
  (define ((indexed lst) grob)
   (list-ref lst (ly:grob-property grob 'glissando-index)))
  (define-event-function
   (left-dy right-dy)
   (number-or-number-list? number-or-number-list?)
   (if (number? left-dy) (set! left-dy (list left-dy)))
   (if (number? right-dy) (set! right-dy (list right-dy)))
   (let ((extra-dy (map (lambda (l r) (- r l)) left-dy right-dy))
         (Y-offset (map (lambda (l r) (/ (+ l r) 2)) left-dy right-dy)))
    #{ \tweak extra-dy #(indexed extra-dy)
       \tweak Y-offset #(indexed Y-offset)
       \glissando #})))

\paper { indent = 0 line-width = 10\cm}

{ f'2 \glissando c''2
  f'2 \offsetGlissando #-1 #-1 c''2
  f'2 \offsetGlissando #1 #1 c''2
  f'2 \offsetGlissando #-2 #0 c''2
  f'2 \offsetGlissando #2 #0 c''2 \break
  f'2 \offsetGlissando #0 #-2 c''2
  f'2 \offsetGlissando #0 #2 c''2 \bar "||"

  \override Glissando.before-line-breaking =
   #(lambda (grob)
     (ly:grob-set-property! grob 'color
      (list-ref (list black red blue)
                (ly:grob-property grob 'glissando-index))))
  <f' a' c''>2 \glissando <c'' g' e'>2
  <f' a' c''>2 \offsetGlissando #'(1 1 -2) #'(-1.5 1.5 0)
  <c'' g' e'>2 \bar "|." }
%%%%

The parameters to \offsetGlissando are delta-Y values for the left and right bounds respectively. If there are multiple glissandi, then the arguments should be lists of numbers, each value corresponding to a particular glissando. Shown above is an untangling of the crossing glissandi, which the coloring should make clearer.

P.S. I am ignoring the possibility of broken glissandi, as they are not supported by default.


-- Aaron Hill

Attachment: offset-glissando.cropped.png
Description: PNG image


reply via email to

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