lilypond-user
[Top][All Lists]
Advanced

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

Re: creating a slur with markup


From: Thomas Morley
Subject: Re: creating a slur with markup
Date: Thu, 27 Jun 2013 01:41:40 +0200

2013/6/27 Rachael Thomas Carlson <address@hidden>:
> On 06/26/2013 05:08 PM, Thomas Morley wrote:
>>
>> \version "2.16.2"
>>
>> \new TabStaff {
>>         \tabFullNotation
>>         \set doubleSlurs = ##t
>>         <c' e>8\2\4( <b d>\2\4)
>> }
>
> Hello Harm:
>
> Thank you for the quick reply.
>
> I think that I could possibly make this work.  Would I manipulate the
> padding of the slur to get them closer to the notes?  Also, how would you
> flip the bottom one 180 degrees?
>
> This example shoes a little bit more of what I am doing:
>
>
> \version "2.16.2"
>
> \new TabStaff {
>     \tabFullNotation
>     \stemDown
>     \set doubleSlurs = ##t
>     \set Staff.stringTunings = \stringTuning <c, g, d g b c'>
>     \override LaissezVibrerTie #'extra-offset = #'(-2.0 . 0.0)
>     <c'^\laissezVibrer e^\laissezVibrer c^\laissezVibrer
> f,^\laissezVibrer>8\2\4\5\6( <b d>\2\4)
> }
>
> The LaissezVibrer on the left of the notes indicate "hammer on from nowhere"
> otherwise known as tapping.  The <c' e> are with the left hand and the <c
> f,> are with the right hand.  In the last couple weeks I have figured out
> quite a bit of hacks to get the tabulature output to be adequate for
> fingerstyle guitar needs.  But this slur issue is giving me some issues.
>
> In the above example the slur that is appearing on the stems of the each
> eighth notes should be appearing on the fourth string, optimally in the 'e'
> and the 'd' in the space above.
>
> Thank you,
> Rachael

Hi Rachael,

per default, LilyPond prints _one_slur between legato-chords. This is
common praxis in nearly all printed editions.
LilyPond provides the possibility to tweak the slurs via their
'control-points. Best use \shape for that purpose.

Sometimes double slurs are wished (mostly between thirds), possible
via \set doubleSlurs = ##t
Though, you can't affect a single slur of this pair with any
implemented method, afaik.
(\shape will affect both with the same values)

Below you'll find my (very hackish) workaround to do so. ;)

Additionally, I changed your code to use repeatTie (and not
extra-offsetting LaissezVibrerTie). There's no need to write it at
every note of the chord, if _all_ note should have it. After the chord
is enough. Perhaps you'll find it sufficient, too.


\version "2.16.2"

shapeDoubleSlur =
#(define-music-function (parser location offsets)(list?)
  (_i "Offset control-points of @code{Slur} by @var{offsets}.
  @code{Slur} is supposed to be invoked by @samp{\\once\\set doubleSlurs = ##t}
  The argument is a list of number pairs or list of such lists.  Each element
  of a pair represents an offset to one of the coordinates of a control-point.")

   (define (read-out l1 l2)
     (define (helper ls1 ls2 ls3)
     "Filters all elements of ls1 from ls2 by their grob-name
      and appends it to ls3"
      (let ((grob-name-proc
              (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name))))
       (if (null? ls1)
           ls3
           (helper
             (cdr ls1)
             ls2
             (append ls3
                     (filter (lambda (x) (eq? (car ls1) (grob-name-proc x)))
                             ls2))))))
    (helper l1 l2 '()))

   ;; Thanks to David Nalesnik for his great shape-functions!!
   (define ((shape-curve offsets) grob)
     (let* ((orig (ly:grob-original grob))
            (siblings (if (ly:spanner? grob)
                          (ly:spanner-broken-into orig) '()))
            (total-found (length siblings))
            (function (assoc-get 'control-points
                                 (reverse (ly:grob-basic-properties grob))))
            (coords (function grob)))

       (define (offset-control-points offsets)
         (if (null? offsets)
             coords
             (map
               (lambda (x y) (coord-translate x y))
               coords offsets)))

       (define (helper sibs offs)
         (if (pair? offs)
             (if (eq? (car sibs) grob)
                 (offset-control-points (car offs))
                 (helper (cdr sibs) (cdr offs)))
             coords))

       ;; we work with lists of lists
       (if (or (null? offsets)
               (not (list? (car offsets))))
           (set! offsets (list offsets)))

       (if (>= total-found 2)
           (helper siblings offsets)
           (offset-control-points (car offsets)))))

#{
  \once\override Slur #'after-line-breaking =
    #(lambda (grob)
      (let* ((sys (ly:grob-system grob))
             (elements-lst
               (ly:grob-array->list (ly:grob-object sys 'all-elements)))
             (grob-name
               (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name)))
             (X-coord (lambda (x) (ly:grob-relative-coordinate x sys X)))
             (Y-coord (lambda (x) (ly:grob-relative-coordinate x sys Y)))
             (grob-y-extent (lambda (x) (ly:grob-extent x sys Y)))
             (slurs (read-out (list 'Slur) elements-lst))
             (slur-X-coord (X-coord grob))
             (relevant-slurs
                 (remove
                   (lambda (slur) (not (= slur-X-coord (X-coord slur))))
                   slurs)))
      (for-each
        (lambda (x y)
          (ly:grob-set-property!
            x
            'control-points
            (shape-curve y)))
        relevant-slurs offsets)
        ))
#})

\version "2.16.2"

\new TabStaff {
    \tabFullNotation
    \stemDown
    \set Staff.stringTunings = \stringTuning <c, g, d g b c'>
    \once \set doubleSlurs = ##t
    \shapeDoubleSlur
    #'(
       ((0 . 7) (0 . 8.0) (0 . 7.7) (0 . 6.4)) ;;bottom
       () ;;top
      )
    <c' e c f,>8\2\4\5\6^\repeatTie ( <b d>\2\4)
}


HTH,
  Harm

Attachment: shape-double-slur.png
Description: PNG image


reply via email to

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