lilypond-user
[Top][All Lists]
Advanced

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

Re: Conditional fermata padding


From: Lukas-Fabian Moser
Subject: Re: Conditional fermata padding
Date: Thu, 8 Sep 2022 12:30:27 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0

Hi Martín,

Am 08.09.22 um 10:52 schrieb Martín Rincón Botero:
I would like to have less padding for a fermata when a note has an accidental. Say, if the fermata has a padding of x, I would like it be x-0.1 or so when the note in question has an accidental. I would be thankful for a snippet :-).

Scripts (like a fermata) can be added to a chord (instead of a single note head); which note's accidentals should then be considered?

Anyway, the following snippet changes the padding of a fermata if _any_ of the note heads in the fermata's note column has an accidental:

\version "2.23.10"

mus = \relative {
  f''4 fis fis <fis cis>
  <fis cis> <fis cis>
}

{
  \override Script.before-line-breaking =
  #(lambda (script-grob)
     (let*
      ((script-cause (ly:grob-property script-grob 'cause))
       (articulation-type (ly:event-property script-cause 'articulation-type))
       (default-padding (ly:grob-property script-grob 'padding))
       (note-column (ly:grob-parent script-grob X))
       (note-heads (ly:grob-array->list
                    (ly:grob-object note-column 'note-heads)))
       (accidentals
        (map
         (lambda (note-head) (ly:grob-object note-head 'accidental-grob))
         note-heads)))
      (if (and (eq? articulation-type 'fermata)
               (any ly:grob? accidentals))
          (ly:grob-set-property! script-grob 'padding
                                 (+ default-padding 2)))))

  \time 2/4
  << \mus \repeat unfold 6 s4\fermata >>
  % tenuto (and staccato, ...) should not be changed
  << \mus \repeat unfold 6 s4\tenuto >>
 
}

Note that this needs a fairly recent LilyPond version, since we changed the 'articulation-type from a string to a symbol at the end of 2021.

Lukas


reply via email to

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