]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/stem-info.cc
release: 0.1.61
[lilypond.git] / lily / stem-info.cc
index 34aadfc976d97f32723a55776f5e433f20e33d31..11990ea3e7e08e3f69f4ef4201244cc46b15c73e 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
+  (c)  1997--1998 Jan Nieuwenhuizen <jan@digicash.com>
 
 */
 
@@ -23,14 +23,13 @@ Stem_info::Stem_info ()
 
 Stem_info::Stem_info (Stem const *s)
 {
-  x = s->hpos_f ();
+  x_ = s->hpos_f ();
   dir_ = s->dir_;
-  beams_i_ =  0 >? (abs (s->flag_i_) - 2);
+  mult_i_ = s->mult_i_;
 
   /*
     [todo] 
-    * get algorithm
-    * runtime
+    * get algorithm runtime
 
     Breitkopf + H\"artel:
     miny_f_ = interline + #beams * interbeam
@@ -45,22 +44,54 @@ Stem_info::Stem_info (Stem const *s)
     */
 
   Real internote_f = s->paper ()->internote_f ();
-  Real interline_f = 2 * internote_f;
-  Real notehead_y = interline_f;
-  // huh? why do i seem to need the / 2 ?
+  Real interline_f = 2.0 * internote_f;
   Real interbeam_f = s->paper ()->interbeam_f ();
-  // Real interbeam_f = s->paper ()->interbeam_f () / 2;
-  // perhaps bo dim (y) = internote?
+  Real staffline_f = s->paper ()->rule_thickness ();
+  Real beam_f = 0.48 * (interline_f - staffline_f);
          
-   idealy_f_  = dir_ * s->stem_begin_f () + beams_i_ * interbeam_f; 
-   if (beams_i_ < 3)
-     idealy_f_ += 2 * interline_f;
-   else
-     idealy_f_ += 1.5 * interline_f;
-   idealy_f_ /= internote_f;
-  miny_f_ = dir_ * s->stem_begin_f () + 2 + beams_i_ * interbeam_f / internote_f;
-
-  idealy_f_ =  miny_f_ >? idealy_f_;
-  //    assert (miny_f_ <= idealy_f_);
+  if (check_debug && !monitor->silent_b ("Stem_info"))
+    {
+      static int i = 1;
+      cout << "******" << i++ << "******" << endl;
+      cout << "begin_f: " << s->stem_begin_f () * dir_ << endl;
+      // urg urg urg
+      cout << "chord_f/i: " << s->chord_start_f () * dir_ / internote_f << endl;
+    }
+
+  /*
+    For simplicity, we'll assume dir = UP and correct if 
+    dir = DOWN afterwards.
+   */
+  idealy_f_ = s->chord_start_f () * dir_ / internote_f;
+  idealy_f_ *= internote_f;
+
+  idealy_f_ += interbeam_f * mult_i_;
+
+  miny_f_ = idealy_f_;
+
+  // B"arenreiter
+  if (mult_i_ < 3)
+    idealy_f_ += 2.0 * interline_f;
+  else
+    idealy_f_ += 1.5 * interline_f;
+
+  miny_f_ += 1.0 * interline_f;
+
+  // lowest beam of (UP) beam must never be lower than second staffline
+  miny_f_ = miny_f_ >? (- 2 * internote_f - beam_f
+    + (mult_i_ > 0) * beam_f + interbeam_f * (mult_i_ - 1));
+
+  idealy_f_ /= internote_f;
+  miny_f_ /= internote_f;
+
+  if (check_debug && !monitor->silent_b ("Stem_info"))
+    {
+      cout << "dir_: " << dir_ << endl;
+      cout << "mult_i_: " << mult_i_ << endl;
+      cout << "idealy_f_: " << idealy_f_ << endl;
+      cout << "miny_f_: " << miny_f_ << endl;
+    }
+
+  idealy_f_ = miny_f_ >? idealy_f_;
 }