lilypond-user
[Top][All Lists]
Advanced

[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: Thu, 25 Oct 2018 12:36:38 +0200

Am Mi., 24. Okt. 2018 um 16:00 Uhr schrieb David Kastrup <address@hidden>:
>
> Thomas Morley <address@hidden> writes:
>
> > 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)))
> > ?
>
> Because 'what-ever-event is not known?  It's been implemented that way
> from its inception in
>
>     commit 1cdc9680f2094525103d335d80bc3950f918ed03
>     Author: Han-Wen Nienhuys <address@hidden>
>     Date:   Sat Feb 3 17:45:22 2007 +0100
>
>         New music function \endSpanners.
>
> It probably was a nuisance to fish out the actual music type name from
> the music expression, so cloning was easier?
>
> I don't really know.
>
> --
> David Kastrup

Well, the code below seems to work here:

endSpanners =
#(define-music-function (music) (ly:music?)
   (_i "Terminate the next spanner prematurely after exactly one note
without the need of a specific end spanner.")
   (let* ((start-span-evs
            (filter
              (lambda (ev) (eqv? (ly:music-property ev 'span-direction) START))
              (extract-typed-music music 'span-event)))
          (stop-span-evs
            (map
              (lambda (m)
                (make-music (ly:music-property m 'name) 'span-direction STOP))
              start-span-evs))
          (end-ev-chord (make-event-chord stop-span-evs))
          (total (make-sequential-music (list music end-ev-chord))))
     total))


%% from NR
\relative c'' {
  \endSpanners
  c2 \startTextSpan c2 c2
  \endSpanners
  c2 \< c2 c2
}


%% input/regression/music-function-end-spanners.ly
\paper{
  ragged-right = ##T
}

\relative
<< {   c''4 c c c }
   \\
   {
     \override TextSpanner.bound-details.left.text = "x"
     \endSpanners c,2\<\startTextSpan c2

   }
 >>

Seems to work sufficiently and cleaner.

I'm tempted to create a patch along these lines.
Though, there is no other usage of 'music-clone' in our code-base, afaict.
It's far to useful to risk someone deletes it lateron regarding it as
unused function.
I think a regtest for 'music-clone' should be created, probably a
snippet (which may be a doc-tagged-LSR-snippet) as well.
I'll have a look through my local usage of 'music-clone', coming back,
if I find some nice usage.

Cheers,
  Harm



reply via email to

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