lilypond-user
[Top][All Lists]
Advanced

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

Re: Different noteheads left/right to the stem


From: Jean Abou Samra
Subject: Re: Different noteheads left/right to the stem
Date: Fri, 03 Mar 2023 17:57:19 +0100
User-agent: Evolution 3.46.4 (3.46.4-1.fc37)

Le vendredi 03 mars 2023 à 08:29 +0100, József Pap a écrit :

Hi all,
Is there a way to print different noteheads to the left and right side of the stem? I have a custom notehead stencil function already, but I can't seem to obtain the necessary information (i.e. whether the notehead will go on left/right side of the stem) from the stencil's scope. I can access the stem grob and read its direction, but it isn't sufficient, since crowded chords have noteheads on both sides.

Here is an example:

\version "2.24.1"

{
  \override NoteHead.stencil =
    #(lambda (grob)
       (let ((stem (ly:grob-object grob 'stem)))
         (ly:grob-property stem 'positioning-done))
       (let* ((note-column (ly:grob-parent grob X))
              (coord (ly:grob-relative-coordinate grob note-column X))
              (is-suspended (< 0.01 (abs coord))))
         (grob-interpret-markup
          grob
          (if is-suspended
              #{ \markup "s" #} ; suspended
              #{ \markup "n" #} ; normal
              ))))
  \override NoteHead.X-extent = #'(0 . 1.3)
  <c' d' e' f' g' a'>
  <a' b' c'' d'' e'' f''>
}

First, you should trigger the stem's positioning-done callback, which is what shares out the note heads between the two sides of the stem. Then, you can read the note head's coordinate relative to its note column.

Note that's it's essential to set X-extent yourself. Here's I've set it to a constant, but you could set it to a callback, as long as it does not read the stencil property. Currently, determining which note heads are on the left or on the right of a chord is not separate from actually placing them (it relates to issue #6103), and while placing them, LilyPond needs their extents, so you would create a cyclic dependency if you read stencil in X-extent.

HTH,

Jean

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


reply via email to

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