]> git.donarmstrong.com Git - lilypond.git/commitdiff
Use upper (beam direction independent) line for per-note concaveness
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 25 Feb 2008 00:18:44 +0000 (21:18 -0300)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 25 Feb 2008 00:18:44 +0000 (21:18 -0300)
check. Fixes beam in the rachmaninov example.

input/regression/beam-concave-chord.ly [new file with mode: 0644]
lily/beam-concave.cc

diff --git a/input/regression/beam-concave-chord.ly b/input/regression/beam-concave-chord.ly
new file mode 100644 (file)
index 0000000..819dce8
--- /dev/null
@@ -0,0 +1,55 @@
+\version "2.11.40"
+
+
+morgenliedBeam = \relative c'' \new Voice{
+  \time 3/8
+  % morgenlied
+  c16 b c e g <e b'> |
+  \stemUp
+  c16 b c e g <e b'> |
+}
+
+rachmaninovBeams = \relative \new Voice {
+  \voiceOne
+  \time 4/4
+  \key c \minor
+  <c' e c'>8 <g c g'> <c f> <ees, ees'>~ <ees ees'> <c c'> <des des'> <d d'>
+}
+
+horizontalBeams = {
+  % todo.
+}
+
+nonHorizontalBeams = {
+  \morgenliedBeam
+  \rachmaninovBeams
+}
+\layout {
+  ragged-right = ##t
+  }
+
+% cut & paste from beam-concave.ly
+
+#(define (<> x y) (not (= x  y)))
+mustBeHorizontal = 
+  \override Staff.Beam #'positions = #(ly:make-simple-closure
+                                (ly:make-simple-closure
+                                 (append
+                                  (list chain-grob-member-functions `(,cons 0 0))
+                                  (check-slope-callbacks =))))
+mustNotBeHorizontal = 
+  \override Staff.Beam #'positions = #(ly:make-simple-closure
+                                (ly:make-simple-closure
+                                 (append
+                                  (list chain-grob-member-functions `(,cons 0 0))
+                                  (check-slope-callbacks <>))))
+
+
+\new Voice {
+  \mustBeHorizontal
+  r1
+  \horizontalBeams
+  \mustNotBeHorizontal
+  \nonHorizontalBeams
+}
+
index e703f9e9f796c62a837fe36843584c32fe70c461..48d45c859945eaa87ded018191bb9ab421b7b640 100644 (file)
@@ -1,5 +1,24 @@
+/* 
+  beam-concave.cc -- implement Concaveness for beams.
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2004 Han-Wen Nienhuys <hanwen@lilypond.org>
+  
+*/
+
 /*
   Determine whether a beam is concave.
+
+  A beam is concave when the middle notes get closer to the
+  beam than the left and right edge notes.
+
+  This is determined in two ways: by looking at the positions of the
+  middle notes, or by looking at the deviation of the inside notes
+  compared to the line connecting first and last.
+
+  The tricky thing is what to do with beams with chords. There are no
+  real guidelines in this case.
 */
 
 #include "pointer-group-interface.hh"
@@ -118,7 +137,6 @@ Beam::calc_concaveness (SCM smob)
        Hmmm.. wait, for the beams in the last measure of morgenlied,
        this doesn't look so good. Let's try the heads farthest from
        the beam.
-
       */
       Interval posns = Stem::head_positions (stems[i]);
 
@@ -128,7 +146,7 @@ Beam::calc_concaveness (SCM smob)
 
   Real concaveness = 0.0;
 
-  if (is_concave_single_notes (far_positions, beam_dir))
+  if (is_concave_single_notes (beam_dir == UP ? close_positions : far_positions, beam_dir))
     {
       concaveness = 10000;
     }