lilypond-user
[Top][All Lists]
Advanced

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

Re: Access a stem’s notehead


From: Paul Morris
Subject: Re: Access a stem’s notehead
Date: Fri, 22 Jan 2016 10:46:14 -0500

> On 22.01.2016 16:11, Simon Albrecht wrote:
>> 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. 

Ok, are there any rests?  If so, you’ll get this error: 

In procedure ly:grob-array-ref in expression (ly:grob-array-ref note-heads 0):
/var/folders/x0/800486lw8xj7t90059bpdlb00000gn/T/frescobaldi-tHHLRO/tmpJg6Ur_/document.ly:7:23:
 Wrong type argument in position 1 (expecting Grob_array): ()

since rests actually have stem grobs (that usually don’t produce visible 
output) but they have no grob array of note heads.  

Below is a version that overrides note head grobs which avoids this rest 
problem.  Also it looks like you don’t need to bother with the note column, as 
it seems these both work directly:

(note-heads-grob-array (ly:grob-object stem-grob 'note-heads))

(stem-grob (ly:grob-object note-head-grob ‘stem))

Cheers,
-Paul

%%%%%%%%%%%%%
\version "2.19.35"
#(define shorten-stem
  (lambda (note-head)
    (let* ((stem (ly:grob-object note-head 'stem))
           (staff-pos (ly:grob-staff-position note-head))
           (stem-len (ly:grob-property stem 'length))
           (delta (case (abs staff-pos)
                    ((3) -0.3)
                    ((2) -1)
                    ((1) -1.5)
                    ((0) -1.8)
                    (else 0))))
      (ly:grob-set-property! stem 'length (+ stem-len delta)))))
mus = { a'4 b' c'' d'' r }
{
 \time 5/4
 \mus
 \override NoteHead.before-line-breaking = #shorten-stem
 \mus
}
%%%%%%%%%%%%





reply via email to

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