lilypond-user
[Top][All Lists]
Advanced

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

NoteHead-stencil-override from inside a LedgerLineSpanner-override


From: Thomas Morley
Subject: NoteHead-stencil-override from inside a LedgerLineSpanner-override
Date: Wed, 25 Jul 2012 00:28:04 +0200

Hi,

I tried to investigate the impacts of an NoteHead-stencil-override,
concerning Accidentals, Stems and LedgerLines using the override below
(representing a more complicated  one).

\override NoteHead #'stencil =
  #(lambda (grob)
    (let* ((stencil (ly:note-head::print grob))
           (new-stil (grob-interpret-markup grob
                (markup #:box #:pad-markup 2 #:stencil stencil))))
    new-stil))

Applying this will move Accidentals and Stems away from the
default-note-head, LedgerLines will be elongated.

With great help from Keith I managed to restore the stem-attachment.
→ http://lists.gnu.org/archive/html/lilypond-user/2012-07/msg00230.html

Now I tried to tackle the LedgerLines. But I found no feasible method
to address the LedgerLines from inside a NoteHead-stencil-override.
And more, it only seems to be possible to manipulate Ledgerlines at
the very start of a voice:
http://lists.gnu.org/archive/html/lilypond-user/2011-04/msg00497.html ff,
or with restarting-staff-trickery.

Well, ok, I tried it the other way. Creating a
LedgerLineSpanner-stencil-override:

I'm able to address the note-heads without problems.
Surprisingly Accidentals and Stems aren't moved, the LedgerLine isn't
elongated (why not?), although I've used the same
stencil-override-code for the note-heads.

Disadvantage:
I have to set \startStaff and \stopStaff which inserts some unwanted
additional space.

%%%%%%%%%%%%%%%%%%

\version "2.15.42"

ls =
\once \override Staff.LedgerLineSpanner #'stencil =
  #(lambda (grob)
    (let* ((stencil (ly:ledger-line-spanner::print grob))
           (default-nh-stil (ly:note-head::print grob))
           (new-nh-stil (grob-interpret-markup grob
                (markup #:box #:pad-markup 1.7 #:stencil default-nh-stil)))
           (note-head-grobs (ly:grob-array->list
                        (ly:grob-object grob 'note-heads)))
           (nh-stencils
             (map!
               (lambda (x) (ly:grob-set-property! x 'stencil new-nh-stil))
                 note-head-grobs))
    )
    nh-stencils
    stencil))

%---test

\relative c' {
        c4 a
        \stopStaff \ls \startStaff
        <cis e''>8[ aeses']
        \stopStaff \revert Staff.LedgerLineSpanner #'stencil \startStaff
        <cis, e''>8 aeses \break
        c4 a <cis e''>8[ aeses'] <cis, e''>8 aeses
}

% I added layout and paper to facilitate comparing the lines.
\paper { indent = 0 }

\layout {
        \context {
                \Staff
                \override TimeSignature #'stencil = #empty-stencil
        }
}

%%%%%%%%%%%%%%%%%%%%

Questions:
How to avoid or reduce the additional space?
Am I using the side-effects of a bug?

Or is a completely other approach overriding NoteHead-stencils thinkable?


Regards,
  Harm



reply via email to

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