lilypond-user
[Top][All Lists]
Advanced

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

Re: Slur position : "catching" Llilypond values...


From: Nick Payne
Subject: Re: Slur position : "catching" Llilypond values...
Date: Tue, 15 Feb 2011 08:03:33 +1100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7

On 15/02/11 02:02, David Nalesnik wrote:
On 2/14/11, Dmytro O. Redchuk<address@hidden>  wrote:

Would be great it if allows to specify which grob's positions to alter, like
this:

\offsetPositions #"Arpeggio" #'(-2 . 2)

Hi, Dmytro --

I actually have been working on a snippet which generalizes another
function -- namely, the oft-cited snippet for applying 'extra-offset
to broken slurs.

http://www.lilypond.org/doc/v2.12/Documentation/user/lilypond/Difficult-tweaks#Difficult-tweaks

It should be easy to do a similar thing with the positions snippet.

Here is my function:

offsetBrokenSpanner =
#(define-music-function (parser location name offsets) (string? pair?)
     #{
       \overrideProperty $name #'after-line-breaking #(broken-spanner $offsets)
     #}
)

#(define ((broken-spanner offsets) grob)
   (let* (
          ; have we been split?
          (orig (ly:grob-original grob))

          ; if yes, get the split pieces (our siblings)
          (siblings (if (ly:grob? orig)
                      (ly:spanner-broken-into orig) '() )))

    (if (and (>= (length siblings) 2)
              (eq? (car (last-pair siblings)) grob))
      (ly:grob-set-property! grob 'extra-offset offsets))))


To modify a slur:

\offsetBrokenSpanner #"Slur" #'(x . y)

To modify a grob in a higher context:

\offsetBrokenSpanner #"Staff.OttavaBracket" #'(x . y)

My only hesitation is this statement in the NR (section referenced above):

"When applying this trick, the new after-line-breaking callback should
also call the old one after-line-breaking, if there is one. For
example, if using this with Hairpin, ly:hairpin::after-line-breaking
should also be called."

I confess I don't fully understand this, and hence I'm unsure if my
function is overly simplifed.  However, calling \offsetBrokenSpanner
#"Hairpin" #'(x . y) seems to work as expected.

[Note: the issue of contexts is why I used \overrideProperty instead
of \override.  For some reason, \override will not accept
"Staff.OttavaBracket" as a valid grob name.  I wonder if there is any
drawback to using \overrideProperty, since I've seen it so
infrequently.]

This is something similar:

\version "2.13.48"

#(define ((grob2-extra-offset offset) grob)
    (let* (
        (orig (ly:grob-original grob))
        (siblings (if (ly:grob? orig)
            (ly:spanner-broken-into orig)
            '())))
    (if (and (>= (length siblings) 2)
        (eq? (car (last-pair siblings)) grob))
    (ly:grob-set-property! grob 'extra-offset offset))))

albOffset = #(define-music-function (parser location type move) (string? pair?) #{ \once \override $type #'after-line-breaking = #(grob2-extra-offset $move)
#})

#(set-global-staff-size 24)

\relative c'' {
    \time 6/4
<< {
        a'8 g fis e dis e \acciaccatura e d4. c'8 b4 |
        c4 r2 s2. |
        dis8 b c b a g b2\rest <e gis,>4 |
    } \\ {
        fis,,,8 e' dis e fis b, c4. g8 a4 |
        dis2 r4 s2. |
        b2 r4 r2. |
    } \\ {
        fis4 s2 s2. |
        s8 e'' fis e g fis ~ fis4. gis8 a4 ~ |
        a4 c,2\rest s2. |
    } \\ {
        s1. |
        c8\rest b a g a c dis4. e,8
        \albOffset "Tie" #'(0 . 1)
        fis4 ~ |
        fis4 s2 fis'8 e dis cis dis b |
    } >>
}

Nick




reply via email to

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