lilypond-devel
[Top][All Lists]
Advanced

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

change `event-chord-wrap!' ?


From: Thomas Morley
Subject: change `event-chord-wrap!' ?
Date: Thu, 21 Apr 2016 23:42:38 +0200

Folks,

we have event-chord-wrap! and is does the job it was designed for pretty good.

Though, sometimes too much: If a single note has instructions for
(stroke-)fingerings and or string-numbers it would make more sense and
be more logical to leave them in the 'articulations of the NoteEvent,
so that it could be affected by setting fingeringOrientations, etc.
Below you'll find some coding doing so.

Questions:
- Do you think it's worth a patch?
- If yes,
  change event-chord-wrap! to this?
  or
  implement an option into event-chord-wrap! ?
  or
  completely separate?

Thanks,
  Harm

\version "2.19.36"

#(define-public (polite-event-chord-wrap! music)
  "Wrap isolated rhythmic events and non-postevent events in
@var{music} inside of an @code{EventChord}.
Events of type @code{FingeringEvent}, @code{StrokeFingerEvent} and
@code{StringNumberEvent} stay in the @code{'articulations} of the rhythmic
event.  Chord repeats @samp{q} are expanded using the default settings of the
parser."
  (map-some-music
   (lambda (m)
     (cond ((music-is-of-type? m 'event-chord)
            (if (pair? (ly:music-property m 'articulations))
                (begin
                  (set! (ly:music-property m 'elements)
                        (append (ly:music-property m 'elements)
                                (ly:music-property m 'articulations)))
                  (set! (ly:music-property m 'articulations) '())))
            m)
           ((music-is-of-type? m 'rhythmic-event)
            (let* ((arts (ly:music-property m 'articulations))
                   (splitted-arts
                     (call-with-values
                       (lambda ()
                         (partition
                           (lambda (x)
                             (or (music-is-of-type? x 'fingering-event)
                                 (music-is-of-type? x 'stroke-finger-event)
                                 (music-is-of-type? x 'string-number-event)))
                           arts))
                       (lambda (a b) (list a b)))))
              (if (pair? arts)
                  (set! (ly:music-property m 'articulations)
                        (car splitted-arts)))
              (make-event-chord (cons m (last splitted-arts)))))
           (else #f)))
   (expand-repeat-notes!
    (expand-repeat-chords!
     (cons 'rhythmic-event
           (ly:parser-lookup '$chord-repeat-events))
     music))))

politeEventChords =
#(define-music-function (music) (ly:music?)
   (_i "Compatibility function wrapping @code{EventChord} around
isolated rhythmic events occuring since version 2.15.28, after
expanding repeat chords @samp{q}.  Possible events of type
@code{FingeringEvent}, @code{StrokeFingerEvent} and
@code{StringNumberEvent} remain in the @code{'articulations} of the rhythmic
event.")
   (polite-event-chord-wrap! music))


\layout {
  \context {
    \Voice
    fingeringOrientations = #'(left)
    strokeFingerOrientations = #'(up)
    stringNumberOrientations = #'(right)
  }
}

\politeEventChords { c''2-1\2 -\rightHandFinger #2  ^"xy"-- }



reply via email to

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