lilypond-user
[Top][All Lists]
Advanced

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

Re: Completion_heads_engraver for line-ends only?


From: Valentin Petzel
Subject: Re: Completion_heads_engraver for line-ends only?
Date: Tue, 17 Jan 2023 22:05:06 +0100

Hello Graham, hello Jean,

this is a proof of concept how something like this could be done (which is not 
necessarily a *should* be done):

\layout {
  \context {
    \Voice
    \remove Note_heads_engraver
    \consists Completion_heads_engraver
    \override Tie.before-line-breaking =
    #(lambda (grob)
       (let* ((h1 (ly:spanner-bound grob LEFT))
              (h2 (ly:spanner-bound grob RIGHT))
              (c1 (ly:grob-property h1 'cause))
              (is_autosplit (ly:event-property c1 'autosplit-end)))
         (if is_autosplit
             (ly:grob-set-object! h1 'completed-tie grob))))
    \override NoteHead.after-line-breaking =
    #(lambda (grob)
       (let* ((ctie (ly:grob-object grob 'completed-tie))
              (otie (if (ly:grob? ctie) (ly:grob-original ctie)))
              (chead (if (ly:grob? otie) (ly:spanner-bound otie RIGHT))))
         (if (ly:grob? chead)
             (let* ((cause (ly:grob-property grob 'cause))
                    (mcause (ly:event-property cause 'music-cause))
                    (mdur (ly:music-property mcause 'duration))
                    (stem (ly:grob-object grob 'stem)))
               (if (null? (ly:spanner-broken-into otie))
                   (begin
                    (ly:grob-suicide! (ly:grob-object chead 'stem))
                    (ly:grob-suicide! chead)
                    (ly:grob-suicide! ctie)
                    (ly:grob-set-property! grob 'duration-log
                                           (ly:duration-log mdur))
                    (ly:grob-set-property! grob 'glyph-name
                                           (note-head::calc-glyph-name grob))
                    (ly:grob-set-property! grob 'stencil
                                           (ly:note-head::print grob))
                    (ly:grob-set-property! stem 'duration-log
                                           (ly:duration-log mdur))))))))
  }
}

{c'4 \repeat unfold 32 c'2 }

The basic idea is to create the completed note heads, and then if it is not 
broken to kill the tie and the completion note head and tweak the first note 
head to look as if it wasn’t split in the first place.

As I said this is a proof of concept and would need lots of additional rules 
to look proper and to handle all cases (what about one note being split 
overmore than two measures? Flags? Beams? Dots? Width of the NoteHead?).

But if one were willing to invest quite some effort into taking care of all of 
these details you’d be able to do this in an acceptable manner.

Alternatively you might use something like (again proof of concept!) to 
automatically get small notes after a line break or something:

\layout {
  \context {
    \Voice
    \remove "Forbid_line_break_engraver"
  }
}

compl = \with {
  \shiftOff
  \remove Note_heads_engraver
  \consists Completion_heads_engraver
  \override Tie.before-line-breaking =
  #(lambda (grob)
     (let* ((h1 (ly:spanner-bound grob LEFT))
            (h2 (ly:spanner-bound grob RIGHT))
            (c1 (ly:grob-property h1 'cause))
            (is_autosplit (ly:event-property c1 'autosplit-end)))
       (if is_autosplit
           (ly:grob-set-object! h1 'completed-tie grob))))
  \override Tie.stencil = ##f
  \override NoteHead.stencil = ##f
  \override Stem.stencil = ##f
  \override NoteHead.after-line-breaking =
  #(lambda (grob)
     (let* ((ctie (ly:grob-object grob 'completed-tie))
            (otie (if (ly:grob? ctie) (ly:grob-original ctie)))
            (chead (if (ly:grob? otie) (ly:spanner-bound otie RIGHT))))
       (if (ly:grob? chead)
           (let* ((cause (ly:grob-property grob 'cause))
                  (mcause (ly:event-property cause 'music-cause))
                  (mdur (ly:music-property mcause 'duration))
                  (stem (ly:grob-object grob 'stem))
                  (stem2 (ly:grob-object chead 'stem)))
             (if (null? (ly:spanner-broken-into otie))
                 (begin
                  (ly:grob-suicide! stem2)
                  (ly:grob-suicide! chead)
                  (ly:grob-suicide! ctie)
                  (ly:grob-suicide! stem)
                  (ly:grob-suicide! grob))
                 (begin
                  (ly:grob-set-property! chead 'stencil
                                         (ly:note-head::print grob))
                  
                  (ly:grob-suicide! stem)
                  (ly:grob-suicide! ctie)
                  (ly:grob-suicide! grob))
                  )))))
  \tiny
  \override NoteColumn.force-hshift = #-0.5
}

\new Staff <<
  {c'4 \repeat unfold 128 c'2 }
  \new Voice \with \compl {c'4 \repeat unfold 128 c'2 }
>>

although this one could be done cleanear with a separarate engraver and grob 
similar to the custos engraver.

Cheers,
Valentin

Am Dienstag, 17. Jänner 2023, 18:56:10 CET schrieb Jean Abou Samra:
> Le 17/01/2023 à 18:31, Graham King a écrit :
> 
> > I'm preparing an edition of de Wert's motet "Ascendente Jesu in naviculam"
> > which has an extended stretto section with dotted rhythms across
> > barlines.  For this, Harm's Mensurstriche example in the Learning Manual
> > produces a mostly beautiful result.
>
> >
> >
> > However, for the sake of those singers who, faced with this passage, find
> > themselves <ahem> all at sea, I would like to avoid notes extending
> > across line-breaks.  The idea is to use something like the
> > Completion_heads_engraver that would take effect only at those barlines
> > that coincide with a line break.  Does such a thing exist?
> 
> 
> 
> I am afraid this would be exceedingly difficult technically.
> Engravers run way earlier than line breaking, so the only
> option would be to let the engraver create both notations
> (with notes straddling over bar lines and with tied notes),
> and remove one of them later, but there is a lot of code in
> between that is not prepared for ignoring the collisions
> that will unavoidably ensue, it would have consequences on
> horizontal spacing, etc.
> 
> Also, I have to say I would find it confusing as a performer.
> In your shoes, I'd go either for modern notation with ties, or
> for ancient notation, but not a mixture of both.
> 
> 
> 
> > As a secondary question: Is there a straightforward way to avoid
> > collisions of mensurstriche with beams?
> 
> 
> Do you have an example?
> 
> Regards,
> Jean
> 

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

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