[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: music-function for ending TextSpanners sometimes fail for skip-event
From: |
Thomas Morley |
Subject: |
Re: music-function for ending TextSpanners sometimes fail for skip-events |
Date: |
Wed, 24 Oct 2018 15:28:12 +0200 |
Am Mi., 24. Okt. 2018 um 01:07 Uhr schrieb David Kastrup <address@hidden>:
>
> Thomas Morley <address@hidden> writes:
>
> > Am Di., 23. Okt. 2018 um 23:54 Uhr schrieb David Kastrup <address@hidden>:
> >
> >> So you should figure out what your comparison as equal is supposed to be
> >> doing in the first place.
> >
> > Yep, that's the culprit.
> >
> > So the question is how to find the last rhythmic event of a
> > music-expression and place <>\stopTextSpan right before it.
>
> Why wouldn't you just put \stopTextSpan on it?
The more or less single reason: because my initial posted function was
modeled after the built-in 'endSpanners' and there it's done this way.
Btw, in the line
(music-clone m 'span-direction STOP))
all music-properties are cloned as well.
Makes not much sense to me. P.e. why should a tweak for
bound-details.left.text of a TextSpanner be copied in the ending
script?
Right now I'm not aware of any property I would want to be copied into
the ending script.
Or did I overlook use-cases?
If not why not simply use a new constructed
(make-event-chord
(list (make-music
'what-ever-event
'span-direction
1)))
?
Back to the topic of this thread.
If someone's interested, I now come up with a code which was built after:
http://lsr.di.unimi.it/LSR/Item?id=83
\version "2.19.82"
%% after 'Adding extra fingering with scheme'
%% http://lsr.di.unimi.it/LSR/Item?id=83
endTextSpanners =
#(define-music-function (parser location music) (ly:music?)
(let ((script #{ \stopTextSpan #})
(do-it? #f)
(last-seen #f))
(define (append-script-at! my-music prop)
(set! (ly:music-property my-music prop)
(append (ly:music-property my-music prop)
(list (ly:music-deep-copy script))))
my-music)
(map-some-music
(lambda (mus)
(case (ly:music-property mus 'name)
((EventChord)
(set! last-seen mus)
(let* ((starts (extract-typed-music mus 'text-span-event)))
(cond ((and (not do-it?) (pair? starts))
(set! do-it? #t)
mus)
((and do-it? (pair? starts))
(append-script-at! mus 'elements))
(else mus))))
((NoteEvent RestEvent SkipEvent)
(set! last-seen mus)
(let* ((starts (extract-typed-music mus 'text-span-event)))
(cond ((and (not do-it?) (pair? starts))
(set! do-it? #t)
mus)
((and do-it? (pair? starts))
(append-script-at! mus 'articulations))
(else mus))))
(else #f)))
music)
(case (ly:music-property last-seen 'name)
((EventChord)
(append-script-at! last-seen 'elements))
((NoteEvent RestEvent SkipEvent)
(append-script-at! last-seen 'articulations))
(else #f))
(set! do-it? #f)
(set! last-seen #f)
music))
\endTextSpanners
{ c'4-3\startTextSpan <c' e' g'>\startTextSpan r s2 }
\endTextSpanners
{
c'4 4\startTextSpan 4 4
\repeat volta 2 {
4\startTextSpan 4
\tuplet 3/2 { 4\startTextSpan 4 <c' e'>4 }
}
}
Cheers,
Harm