lilypond-user
[Top][All Lists]
Advanced

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

Changing the "midpoint" of a custom staff for stem direction purposes


From: Paul Morris
Subject: Changing the "midpoint" of a custom staff for stem direction purposes
Date: Fri, 8 Feb 2013 15:35:56 -0500

Hello everyone,

Here's another obscure question.  If you change the line-positions to create a custom staff, for example to have a 4-line staff, what is the best way to also change the "midpoint" of the staff, so that the stem directions are correct for the altered staff?  (Notes should get upwards stems in the bottom half of the staff, and downward stems in the top half.)

I've gotten pretty far with the approach below.  It seems to work, but then it does not work for beamed 8th notes.  

(I started by setting the stem's "direction" instead of "default-direction", but that works "too well" and results in beaming problems -- see attached image.)

Internals Reference for Stem:
http://www.lilypond.org/doc/v2.16/Documentation/internals/stem

Any suggestions appreciated,
-Paul


%%% BEGIN

 \version "2.16.1"

#(define (stemDirectionHandler midpoint)
  (lambda (grob)
    (let* (                  
      (notecol (ly:grob-parent grob X))
      (stm (ly:grob-object notecol 'stem))
      (ypos (ly:grob-staff-position grob)))
      
      (if (< ypos midpoint) 
        (set! (ly:grob-property stm 'default-direction) 1)
        (set! (ly:grob-property stm 'default-direction) -1))
)))

theMusic = \relative c' { 
  c4 d e f g a b c d e f g a b
  \time 2/4
  r8 c,,8 d e f g a b c d e f g a b
}

\score {
  \new Staff \with {
      \override StaffSymbol #'line-positions = #'( 1 3 5 7 )
      \override NoteHead #'before-line-breaking = #(stemDirectionHandler 4)
      \override Stem #'no-stem-extend = ##t
      \remove "Clef_engraver"
      \remove "Time_signature_engraver"
  } 
  {\theMusic }
  
  \layout {}
}

%%% END



reply via email to

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