From 60449ea328561f484249b960f4201ac4e51badc7 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 24 Feb 2008 21:18:44 -0300 Subject: [PATCH] Use upper (beam direction independent) line for per-note concaveness check. Fixes beam in the rachmaninov example. --- input/regression/beam-concave-chord.ly | 55 ++++++++++++++++++++++++++ lily/beam-concave.cc | 22 ++++++++++- 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 input/regression/beam-concave-chord.ly 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 | + \stemUp + c16 b c e g | +} + +rachmaninovBeams = \relative \new Voice { + \voiceOne + \time 4/4 + \key c \minor + 8 ~ +} + +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 + +*/ + /* 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; } -- 2.39.2