[Top][All Lists]

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

Re: vertical shift of trill

From: Jean Abou Samra
Subject: Re: vertical shift of trill
Date: Sat, 6 Aug 2022 15:55:41 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0

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.


\version "2.22.0"

\layout {
  \context {
    \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
   des c1*7/8 s8 \stopTrillSpan }\\{\pitchedTrill
   \startTrillSpan bes a1*7/8 s8 \stopTrillSpan}>>

  \clef treble
  \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


reply via email to

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