From 5642c6ee7b38dd7bd40bbf78ba78f7add6bf1610 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Tue, 13 Aug 2002 12:51:02 +0000
Subject: [PATCH] * input/test/stem.ly: *
 input/mutopia/J.S.Bach/baerenreiter-sarabande.ly: Play with beamed-lengths.

* input/test/spacing.ly: Give enough room to test spacing.
---
 ChangeLog                                     |  6 ++
 input/les-nereides.ly                         |  4 +
 .../J.S.Bach/baerenreiter-sarabande.ly        | 12 +--
 input/test/spacing.ly                         |  4 +-
 input/test/stem.ly                            | 92 ++++++++++++-------
 lily/beam-quanting.cc                         | 42 +++++----
 lily/beam.cc                                  | 13 +--
 7 files changed, 100 insertions(+), 73 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1967206c69..ed31b8b21e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2002-08-13  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+	* input/test/stem.ly:
+	* input/mutopia/J.S.Bach/baerenreiter-sarabande.ly: Play with
+	beamed-lengths.
+
+	* input/test/spacing.ly: Give enough room to test spacing.
+
 	* cygwin/post-lilypond.sh: Fix and update.
 
 	* cygwin/zlily-profile.sh: Remove.
diff --git a/input/les-nereides.ly b/input/les-nereides.ly
index 6b2ba4bf5b..63ac72d446 100644
--- a/input/les-nereides.ly
+++ b/input/les-nereides.ly
@@ -351,3 +351,7 @@ lowerDynamics =  \context Dynamics=lower \notes{
         }
     }
 }
+
+%%% Local variables:
+%%% LilyPond-indent-level:4
+%%% End:
diff --git a/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly b/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly
index 37b8d8a768..2f00f25f85 100644
--- a/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly
+++ b/input/mutopia/J.S.Bach/baerenreiter-sarabande.ly
@@ -1,4 +1,4 @@
-
+\version "1.5.68"
 
 #(set! point-and-click line-column-location)
 
@@ -49,9 +49,6 @@ half way in measure 13 has been forgotten.
 }
 
 
-\version "1.5.68"
-
-
 sarabandeA =  \context Voice \notes \relative c {
   \property Staff.NoteCollision \set #'merge-differently-dotted = ##t
   < { d8. e16 e4.-\trill d16 e } \\
@@ -140,8 +137,6 @@ sarabande =  \context Staff \notes<
   
 >
 
-\version "1.5.68"
-
 sarabandeCelloGlobal =  \notes{
   \time 3/4
   \key f \major
@@ -156,7 +151,12 @@ sarabandeCelloGlobal =  \notes{
 sarabandeCelloScripts =  \notes{
 }
 
+  #(warn "FIXME: Setting beamed lengths")
 sarabandeCelloStaff =  \context Staff <
+  %%#(warn "FIXME: Setting beamed lengths")
+  %%\notes c4*0-#(warn "FIXME: Setting beamed lengths")
+  \property Staff.Stem \set #'beamed-lengths = #'(3.26)
+  
   \sarabande
   \sarabandeCelloGlobal
   \sarabandeCelloScripts
diff --git a/input/test/spacing.ly b/input/test/spacing.ly
index eeafb90387..2f2c351231 100644
--- a/input/test/spacing.ly
+++ b/input/test/spacing.ly
@@ -91,7 +91,7 @@ singlepart =  \notes{
 	\multipart 
     }
     \paper {
-%    linewidth= 18.\cm
-
+      indent = 0.0 \cm
+      linewidth= 20.0\cm
     }
 }
diff --git a/input/test/stem.ly b/input/test/stem.ly
index a64bc6a839..d2a023f242 100644
--- a/input/test/stem.ly
+++ b/input/test/stem.ly
@@ -1,45 +1,67 @@
 \version "1.5.68"
 \header{
-title= "Stems and Beams"
-subtitle =  "proofsheet" 
-enteredby = 	 "jcn"
-copyright = 	 "public domain"
-TestedFeatures = 	 "This file tests the length of stems and placement 
+  title= "Stems and Beams"
+  subtitle =  "proofsheet" 
+  enteredby = 	 "jcn"
+  copyright = 	 "public domain"
+  TestedFeatures = 	 "This file tests the length of stems and placement 
 of beams"
-	
+  
 }
 
 
 
-beamintervals =  \notes{
-		\time 7/4
-		\stemUp
-\transpose c'{
-		[ c8 d ] [ c e ] [ c f ] [ c g ] [ c a ] [ c b ] [ c c' ] |
-		[ c b, ] [ c a, ] [ c g, ] [ c f, ] [ c e, ] [ c d, ] [ c c, ] |
-		}\transpose c''{
-		[ c b, ] [ c a, ] [ c g, ] [ c f, ] [ c e, ] [ c d, ] [ c c, ] |
-		\stemDown}
-		\transpose c'''{
-		[ c b, ] [ c a, ] [ c g, ] [ c f, ] [ c e, ] [ c d, ] [ c c, ] |
-}		\transpose c''{
-		[ c b, ] [ c a, ] [ c g, ] [ c f, ] [ c e, ] [ c d, ] [ c c, ] |
-		[ c d ] [ c e ] [ c f ] [ c g ] [ c a ] [ c b ] [ c c' ] |
-	}}
+beamintervals = \notes{
+  \time 7/4
+  \stemUp
+  \transpose c''{
+    [ c8 d ] [ c e ] [ c f ] [ c g ] [ c a ] [ c b ] [ c c' ] |
+    [ c b, ] [ c a, ] [ c g, ] [ c f, ] [ c e, ] [ c d, ] [ c c, ] |
+  }
+  \transpose c'''{
+    [ c b, ] [ c a, ] [ c g, ] [ c f, ] [ c e, ] [ c d, ] [ c c, ] |
+    \stemDown
+  }
+  \transpose c''''{
+    [ c b, ] [ c a, ] [ c g, ] [ c f, ] [ c e, ] [ c d, ] [ c c, ] |
+  }
+  \transpose c'''{
+    [ c b, ] [ c a, ] [ c g, ] [ c f, ] [ c e, ] [ c d, ] [ c c, ] |
+    [ c d ] [ c e ] [ c f ] [ c g ] [ c a ] [ c b ] [ c c' ] |
+  }
+}
 
 \score{
-	\notes\transpose c'{ 
-		\stemUp
-		\time 17/4
-		g,4 a, b, c d e f g a b c' d' e' f' g' a' b' |
-		\stemDown
-		b' a' g' f' e' d' c' b a g f e d c b, a, g, |
-		\beamintervals
-		\transpose d \beamintervals
-		\transpose e \beamintervals
-		\transpose f \beamintervals
-		\transpose g \beamintervals
-		\transpose a \beamintervals
-		\transpose b \beamintervals
-	}
+  \notes{
+    \time 19/4
+
+    %% 3.50 (standard) - 0.24 (beam-thickness / 2) = 3.26 ...
+    %% yields beams almost as [Ross] wants them.
+    
+    %% Differences are only half a beam-thickness, probably giving
+    %% Lily's beams a slightly better slope
+    
+    \property Staff.Stem \set #'beamed-lengths = #'(3.26)
+
+    \relative c'{
+      \stemUp
+      g4 a b c d e f g a b c d e f g a b c d
+      \stemDown
+      d c b a g f e d c b a g f e d c b a g
+    }      
+    \beamintervals
+    \transpose d' \beamintervals
+    \transpose e' \beamintervals
+    \transpose f' \beamintervals
+    \transpose g' \beamintervals
+    \transpose a' \beamintervals
+    \transpose b' \beamintervals
+  }
+  \paper{
+    indent = 0.0\mm
+    }
 }
+
+%%% Local variables:
+%%% LilyPond-indent-level:2
+%%% End:
diff --git a/lily/beam-quanting.cc b/lily/beam-quanting.cc
index e3fa99efb1..c589e5da37 100644
--- a/lily/beam-quanting.cc
+++ b/lily/beam-quanting.cc
@@ -1,3 +1,15 @@
+/*
+  beam-quanting.cc -- implement Beam quanting functions
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  Jan Nieuwenhuizen <janneke@gnu.org>
+  
+*/
+
+
+
 #include <math.h>
 
 #include "grob.hh"
@@ -181,13 +193,10 @@ Beam::quanting (SCM smob)
 	qscores.push (qs);
       }
 
-  /*
-    This is a longish function, but we don't separate this out into
-    neat modular separate subfunctions, as the subfunctions would be
-    called for many values of YL, YR. By precomputing various
-    parameters outside of the loop, we can save a lot of time.
-  */
-
+  /* This is a longish function, but we don't separate this out into
+     neat modular separate subfunctions, as the subfunctions would be
+     called for many values of YL, YR. By precomputing various
+     parameters outside of the loop, we can save a lot of time. */
   for (int i = qscores.size (); i--;)
     {
       qscores[i].demerits
@@ -197,9 +206,7 @@ Beam::quanting (SCM smob)
 
   Real rad = Staff_symbol_referencer::staff_radius (me);
   int beam_count = get_beam_count (me);
-  Real beam_translation = beam_count < 4
-    ? (2*ss + slt - thickness) / 2.0
-     : (3*ss + slt - thickness) / 3.0;
+  Real beam_translation = get_beam_translation (me);
 
   Real reasonable_score = (knee_b) ? 200000 : 100;
   for (int i = qscores.size (); i--;)
@@ -268,18 +275,13 @@ Beam::score_stem_lengths (Link_array<Grob>stems,
       Stem_info info = stem_infos[i];
       Direction d = info.dir_;
 
-      score[d] += pen
-	* (0 >? (d * (info.shortest_y_ - current_y)));
+      score[d] += pen * (0 >? (d * (info.shortest_y_ - current_y)));
 
-      Real ideal_score = shrink_extra_weight (d * current_y  - d * info.ideal_y_);
+      Real ideal_score = shrink_extra_weight (d * (current_y - info.ideal_y_));
       
-      /*
-
-      we introduce a power, to make the scoring strictly
-      convex. Otherwise a symmetric knee beam (up/down/up/down) does
-      not have an optimum in the middle.
-	
-       */
+      /* We introduce a power, to make the scoring strictly
+         convex. Otherwise a symmetric knee beam (up/down/up/down)
+         does not have an optimum in the middle. */
       if (knee)
 	ideal_score = pow (ideal_score, 1.1);
       score[d] += STEM_LENGTH_DEMERIT_FACTOR * ideal_score;
diff --git a/lily/beam.cc b/lily/beam.cc
index 731dcb3e6e..3e9c31f66c 100644
--- a/lily/beam.cc
+++ b/lily/beam.cc
@@ -11,9 +11,6 @@
 /*
 TODO:
 
-
-  * Junk stem_info.
-
   * Use Number_pair i.s.o Interval to represent (yl, yr).
   
   - Determine auto knees based on positions if it's set by the user.
@@ -70,9 +67,7 @@ Beam::add_stem (Grob *me, Grob *s)
 }
 
 
-/*
-  this returns the translation between 2 adjoining beams.
- */
+/* Return the translation between 2 adjoining beams. */
 Real
 Beam::get_beam_translation (Grob *me)
 {
@@ -1154,10 +1149,8 @@ where_are_the_whole_beams(SCM beaming)
   return l;
 }
 
-/*
-  Calculate the Y position of the stem-end, given the Y-left, Y-right
-  in POS for stem S. This Y position is relative to S.
- */
+/* Return the Y position of the stem-end, given the Y-left, Y-right
+   in POS for stem S.  This Y position is relative to S. */
 Real
 Beam::calc_stem_y (Grob *me, Grob* s, Grob ** common,
 		   Real xl, Real xr,
-- 
2.39.5