lilypond-user
[Top][All Lists]
Advanced

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

Re: Text Spanner auto expand to end of duration


From: Thomas Morley
Subject: Re: Text Spanner auto expand to end of duration
Date: Mon, 8 Feb 2021 00:01:23 +0100

Am Sa., 6. Feb. 2021 um 20:07 Uhr schrieb Dimitris Marinakis
<dtsmarin02@gmail.com>:
>
> Aha! Found the culprit. As you can see if other staves have different 
> durations (shorter than the span that needs to be covered), the spanner 
> terminates at the first next duration it finds. Could you make the spanner to 
> see only the relevant duration of the context it is applied to? Voice, Staff 
> etc.?
> Apologies for the redundant erroneous mails.
> Dimitris
> %%%%%%%%%%%%%%%%%%%%%
> \version "2.23.0"
[...]

I don't know any method to do so by amending the current coding.
An engraver could likely work:

\version "2.22.0"

Test_engraver =
#(lambda (context)
  (let* ((rhythmic-events '())
         (bar-line #f)
         (end-spanner #f)
         (trill-spanner #f))
    (make-engraver
      (listeners
        ((rhythmic-event this-event event)
          ;; store moments for all rhythmic events
          ;; NB this will include skip-events
          (set! rhythmic-events
                (cons (ly:context-current-moment context) rhythmic-events))))

      (acknowledgers
        ((bar-line-interface this-engraver grob source-engraver)
          ;; keep track of BarLine
          (set! bar-line (cons (ly:context-current-moment context) grob)))
        ((trill-spanner-interface this-engraver grob source-engraver)
          (set! end-spanner #t)
          ;; keep track of TrillSpanner
          (if (ly:grob-property grob 'full-length-to-extent #f)
              (set! trill-spanner grob))))

      ((stop-translation-timestep this-engraver)
        (if (ly:grob? trill-spanner)
            (let ((right-bound (ly:spanner-bound trill-spanner RIGHT)))
              (if (and (ly:grob? right-bound) (>= (length rhythmic-events) 2))
                  (let* ((curr-moment (ly:context-current-moment context))
                         (to-barline?
                           (ly:grob-property trill-spanner 'to-barline #f)))
                    (if (and (equal? (grob::when right-bound)
                                     (second rhythmic-events))
                             end-spanner)
                      (begin
                        ;; set right bound of the TrillSpanner to the BarLine
                        ;; if 'to-barline is enabled, otherwise to current
                        ;; PaperColumn
                        (ly:spanner-set-bound! trill-spanner RIGHT
                          (if (and to-barline?
                                   (equal? (car bar-line) curr-moment))
                              (cdr bar-line)
                              (ly:context-property
                                context 'currentMusicalColumn)))
                        (set! end-spanner #f))))))))

      ((finalize this-engraver)
        ;; house keeping
        (set! trill-spanner #f)
        (set! rhythmic-events '())
        (set! bar-line #f)))))

instrumentOne = \relative c' {
  \override TrillSpanner.to-barline = ##f
  \override TrillSpanner.full-length-to-extent = ##t
  c4 d\startTrillSpan e f |
  R1 |
  d'2\stopTrillSpan\startTrillSpan c | b a |
  b2  g2 | f2 f2\stopTrillSpan |
  e e e e |
}

instrumentTwo = \relative g' {
  R1 |
  R1 |
  R1 |
  R1 |
  R1 |
  R1 |
  R1 |
}

instrumentThree = \relative g' {
  a4 b c d e f d e c b a d g f e d c b c d e f e d c1
}

\layout {
  \context {
      \Staff
      \consists \Test_engraver
  }
}

<<
  \new Staff \instrumentTwo
  \new Staff \instrumentOne
>>

<<
  \new Staff \instrumentThree
  \new Staff \instrumentOne
>>


You can switch it of by setting
  \override TrillSpanner.full-length-to-extent = ##f

'full-length-to-extent is a property stolen from
'tuplet-bracket-interface. Meaning it is an established grob-property,
but will issue:
    programming error: Grob `TrillSpanner' has no interface for
property `full-length-to-extent'
if you compile with the check-internal-types option.

Cheers,
  Harm



reply via email to

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