From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Date: Mon, 25 Feb 2008 00:18:44 +0000 (-0300)
Subject: Use upper (beam direction independent) line for per-note concaveness
X-Git-Tag: release/2.11.41-1~6
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=60449ea328561f484249b960f4201ac4e51badc7;p=lilypond.git

Use upper (beam direction independent) line for per-note concaveness
check. Fixes beam in the rachmaninov example.
---

diff --git a/input/regression/beam-concave-chord.ly b/input/regression/beam-concave-chord.ly
new file mode 100644
index 0000000000..819dce8948
--- /dev/null
+++ b/input/regression/beam-concave-chord.ly
@@ -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
+}
+
diff --git a/lily/beam-concave.cc b/lily/beam-concave.cc
index e703f9e9f7..48d45c8599 100644
--- a/lily/beam-concave.cc
+++ b/lily/beam-concave.cc
@@ -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;
     }