[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Access a stem’s notehead
From: |
Simon Albrecht |
Subject: |
Re: Access a stem’s notehead |
Date: |
Fri, 22 Jan 2016 16:11:39 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 |
On 22.01.2016 14:26, Paul Morris wrote:
On January 22, 2016 7:47:11 AM EST, Simon Albrecht <address@hidden> wrote:
How do I retrieve the
NoteHead from the Column?
Hi Simon, this snippet should help:
http://lsr.di.unimi.it/LSR/Item?id=621
It shows how to get a Stem from a NoteHead, using ly:grob-object
Thanks, Paul and Abraham, for your help. ly:grob-object was the way to go:
%%%%%%%%%%%%%
\version "2.19.35"
#(define shorten-stem
(lambda (grob)
(let* ((note-col (ly:grob-parent grob 0))
(note-heads (ly:grob-object note-col 'note-heads)) ; is a
Grob array
(note-head (ly:grob-array-ref note-heads 0)) ; we don’t
have chords anyway
(staff-pos (ly:grob-staff-position note-head))
(stem-len (ly:grob-property grob 'length))
(delta (case (abs staff-pos)
((3) -0.3)
((2) -1)
((1) -1.5)
((0) -1.8))))
(ly:grob-set-property! grob 'length (+ stem-len delta)))))
mus = { a'4 b' c'' d'' e'' }
{
\time 5/4
\mus
\override Stem.before-line-breaking = #shorten-stem
\mus
}
%%%%%%%%%%%%
That way may be simpler than going from Stem to NoteHead (one Stem per
NoteHead, potentially many NoteHeads per Stem).
The feature is designed for a very specific case: Renaissance vocal
music, one voice per staff, no chords, no dynamics etc. With this
callback, I crop those stems which protrude beyond the staff, such as to
allow for still closer vertical spacing.
Yours, Simon
Re: Access a stem’s notehead, tisimst, 2016/01/22