Hi Jean, that is beautiful. I’m always impressed by your vast understanding of each single (not even documented) detail of Lilypond!
Best, Valentin Am Samstag, 6. August 2022, 15:55:41 CEST schrieb Jean Abou Samra: > Hi Valentin, > > Le 06/08/2022 à 15:05, Valentin Petzel a écrit : > > But we can in fact implement a simple function that tries to fit the > > TrillSpanner (or in fact any spanner) to the notes. Consult the appended > > file for details. > > FYI, the bulk of this function can be simplified using > ly:relative-group-extent. That said, there's a much simpler > way. Your function is essentially reimplementing part of > the side-position-interface. TrillSpanner has its Y offset > computed by side-position-interface::y-aligned-side, so apart > from outside-staff-priority handling, it will avoid objects > in its side-support-elements array. The problem here is that > by default, LilyPond doesn't fill in this array. On the other > hand, Trill_spanner_engraver fills a note-columns array > which contains exactly what you want, so you can just use that: > > > \override TrillSpanner.meta.object-callbacks.side-support-elements = > #(lambda (grob) > (ly:grob-object grob 'note-columns)) > > Add \override TrillSpanner.staff-padding = ##f and > side-position-interface::y-aligned-side will no longer > push the object out of the staff. > > Also, instead of defining functions tweaking the direction, > I'd suggest allowing the syntax with _ and ^ by looking > at the event's direction property. > > Giving: > > > \version "2.22.0" > > \layout { > \context { > \Score > \override TrillSpanner.outside-staff-priority = ##f > \override TrillSpanner.staff-padding = ##f > \override TrillSpanner.meta.object-callbacks.side-support-elements = > #(lambda (grob) > (ly:grob-object grob 'note-columns)) > \override TrillSpanner.direction = > #(lambda (grob) > (let ((ev (event-cause grob))) > (ly:event-property ev 'direction UP))) > } > } > > mus = \relative c'' { > <<{ \pitchedTrill > c'1~^\f > \startTrillSpan > des c1*7/8 s8 \stopTrillSpan }\\{\pitchedTrill > a1~\f > \startTrillSpan bes a1*7/8 s8 \stopTrillSpan}>> > } > > { > \clef treble > \mus > \transpose c a, \mus > \transpose c fis, \mus > \transpose c c, \mus > \transpose c a,, \mus > \transpose c fis,, \mus > \transpose c c,, \mus > } > > % Using TrillSpanner.padding to correct distance > { > f''1_\startTrillSpan ~ 1 \stopTrillSpan > 1\tweak padding 0 _\startTrillSpan ~ 1 \stopTrillSpan > 1\tweak padding 2 _\startTrillSpan ~ 1 \stopTrillSpan > 1\tweak padding -1 _\startTrillSpan ~ 1 \stopTrillSpan > } > > > Best, > Jean
signature.asc
Description: This is a digitally signed message part.