lilypond-user
[Top][All Lists]
Advanced

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

Re: Apply event function *within* music-function


From: Jan-Peter Voigt
Subject: Re: Apply event function *within* music-function
Date: Tue, 2 May 2017 18:08:39 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0

Hi Urs,

Am 02.05.2017 um 17:30 schrieb Urs Liska:
Hi Jan-Peter

...
\version "2.19.57"

test =
#(define-music-function (mus)(ly:music?)
   (let* ((elms (ly:music-property mus 'elements))
          ; first and last music-element ...
          (frst (first elms)) ; TODO test for list? and ly:music?
          (lst (last elms)) ; TODO test for list? and ly:music?
          (fartic (ly:music-property frst 'articulations '())) ; look
for eventchords ...
          (lartic (ly:music-property lst 'articulations '()))
          )
     (ly:music-set-property! frst 'articulations `(,@fartic
,(make-music 'NoteGroupingEvent 'span-direction -1)))
     (ly:music-set-property! lst 'articulations `(,@lartic
,(make-music 'NoteGroupingEvent 'span-direction 1)))
   #{
     #mus
   #}))

\new Staff \with {
  \consists "Horizontal_bracket_engraver"
} {
  \test { c' d' e' f' } g' a' b' c''
}


HTH

Yes, it does. I don't think there's an even more straightforward
solution (like the <> for the first element) to this. I successfully
integrated it into my code.
But what would be the cases where the element is a list? instead of
ly:music? And what does the "eventchords" comment refer to?
If you have an eventchord (e.g. <c e g>) there will be no articulations property in that element. That means, you have to add the NoteGroupingEvent to the elements list. In other words: If you have something other than a simple note- or rest-event inside the mus argument, this solution might fail. You probably need to transcend the music tree, until you find an event appropriate for add the NoteGroupingEvent. As long as you take care that the first and the last element is such an element it should be fine.

Cheers
Jan-Peter




reply via email to

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