lilypond-user
[Top][All Lists]
Advanced

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

Re: A problem with "placing grace notes between arpeggios and chords"


From: Thomas Morley
Subject: Re: A problem with "placing grace notes between arpeggios and chords"
Date: Tue, 14 Nov 2017 17:39:21 +0100

2017-11-14 13:23 GMT+01:00 Robert Blackstone <address@hidden>:
> Hello,
>
> Snippet http://lsr.di.unimi.it/LSR/Item?id=410 shows an excellent way to 
> insert a grace note between an arpeggio and the arpeggiated chord

Looking at the snippet, I thought what a mess. All those added Voices,
hide and unhide Notes, ignore-collision ...

Thus I come up with below.
Single draw-back so far: you'll need to use \grace and add the Slur manually.


\version "2.19.65"

#(define set-arpeggio-position
;; Sets Arpeggio.positions taken from the chord's note-heads ending the Slur
  (lambda (grob)
    (if (grob::has-interface grob 'slur-interface)
        (let* ((right-bound (ly:spanner-bound grob RIGHT))
               (right-note-column
                 (if (grob::has-interface right-bound 'note-column-interface)
                     right-bound
                     (ly:grob-parent right-bound X)))
               (left-bound (ly:spanner-bound grob LEFT))
               (left-note-column (ly:grob-parent left-bound X))
               (staff-space
                 (ly:output-def-lookup (ly:grob-layout grob) 'staff-space))
               (note-heads (ly:grob-object right-note-column 'note-heads))
               (staff-pos-ls
                 (if (ly:grob-array? note-heads)
                     (sort
                       (map
                         (lambda (nh)
                           (ly:grob-property nh 'staff-position))
                         (ly:grob-array->list note-heads))
                        <)
                     #f))
               (cond-elts (ly:grob-object left-bound 'conditional-elements))
               (arp-ls
                 (if (ly:grob-array? cond-elts)
                     (filter
                       (lambda (arp)
                         (grob::has-interface arp 'arpeggio-interface))
                       (ly:grob-array->list cond-elts))
                     '()))
               (arp (if (pair? arp-ls) (car arp-ls) #f))
               (arp-pos
                 (if staff-pos-ls
                     (interval-widen
                       (cons
                         (/ (car staff-pos-ls) 2)
                         (/ (last staff-pos-ls) 2))
                       (/ staff-space 2))
                     #f)))
          (if (and arp arp-pos)
              (ly:grob-set-property! arp 'positions arp-pos))
        #f))))

setArpeggioPosition =
\once \override Slur.before-line-breaking = #set-arpeggio-position

<<
  \new Staff {
    \key ees \major

    \override PhrasingSlur.positions = #'(2.5 . 2.2)
    \phrasingSlurUp

    <bes d' f'>4\(
    <bes des' ees' g'>
    \setArpeggioPosition
    %% probably adjust the Slur a little:
    \once \override Slur.minimum-length = 2
    \shape #'((0 . 0) (-0.2 . -0.2) (-0.2 . -0.3) (-0.2 . -0.4)) Slur
    \grace bes'8(\arpeggio
    <c' es' aes')>4
    <bes e' g'>\fermata\)

    <aes c' f'>\(
    <g c' ees'>
    \setArpeggioPosition
    %% probably adjust the Slur a little:
    \once \override Slur.minimum-length = 2
    \shape #'((0 . 0) (-0.2 . -0.2) (-0.2 . -0.3) (-0.2 . -0.4)) Slur
    \grace g'8(\arpeggio
    <aes c' f')>4
    <g c' ees'>\fermata\)
  }

  \new Staff {
    \clef bass
    \key es \major
    bes,4 es as, c,\fermata |
    <f, c>
    <c, c>
    <f, c>
    <c, c>\fermata
  }
>>

Regards,
  Harm



reply via email to

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