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: Simon Albrecht
Subject: Re: Access a stem’s notehead
Date: Fri, 22 Jan 2016 16:57:22 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1

On 22.01.2016 16:41, Simon Albrecht wrote:
On 22.01.2016 16:30, Simon Albrecht wrote:
Oops, there was an else-statement missing.

And it didn’t work with rests.

What’s more, we have to avoid programming errors if there are beams. I’m learning a lot at this…

%%%%%%%%%%%%%%%%%%
\version "2.19.35"
#(define crop-outside-staff-stem
   (lambda (grob)
     (let* ((note-col (ly:grob-parent grob 0))
            (note-heads (ly:grob-object note-col 'note-heads))
            (has-note-head? (not (eq? '() note-heads)))
            (no-beam? (eq? '() (ly:grob-object grob 'beam))))
       (if (and has-note-head? no-beam?)
(let* ((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)
                            (else 0))))
             (ly:grob-set-property! grob 'length (+ stem-len delta)))))))

mus = \relative { a'4 b c d e f g a8 a,, }

{
  \mus
  \override Stem.before-line-breaking = #crop-outside-staff-stem
  \mus
}
%%%%%%%%%%%%%

Best, Simon



reply via email to

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