]> git.donarmstrong.com Git - lilypond.git/commitdiff
stem tremolo fix
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 23 May 2002 22:07:32 +0000 (22:07 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Thu, 23 May 2002 22:07:32 +0000 (22:07 +0000)
Documentation/user/invoking.itexi
lily/beam.cc
lily/chord-tremolo-engraver.cc
lily/include/stem.hh
lily/slur.cc
lily/stem-tremolo.cc
lily/stem.cc
make/lilypond.redhat.spec.in

index 36a219557f8ee20cca214e121cc57014215572ab..754f8d4d4d5bf4577e6d0bc829fb6ef0d0d3b84f 100644 (file)
@@ -38,7 +38,9 @@ have appropriate environment variables set.  For @TeX{}, you have to
 set @code{MFINPUTS} and @code{TEXINPUTS} to point to the directory
 containing LilyPond metafont and @file{.tex} files.  For processing
 PostScript output with Ghostscript you have to set @code{GS_FONTPATH}
-to point to the directory containing LilyPond PFA files.
+to point to the directory containing LilyPond PFA files.  When you
+print direct PS output, remember to send the PFA files to the printer
+as well.
 
 Scripts to do this are included in
 @file{buildscripts/out/lilypond-profile} (for sh shells) and
index ac715ee9f2feb3a032fb9b81c09bd9e54a89b63b..b75537e2a8dec3e6978a5a78ab2d0269ae4d4bab 100644 (file)
@@ -735,8 +735,8 @@ Beam::least_squares (SCM smob)
   
   if (!ideal.delta ())
     {
-      Interval chord (Stem::chord_start_f (first_visible_stem (me)),
-                     Stem::chord_start_f (last_visible_stem (me)));
+      Interval chord (Stem::chord_start_y (first_visible_stem (me)),
+                     Stem::chord_start_y (last_visible_stem (me)));
 
 
       /*
@@ -831,16 +831,16 @@ Beam::check_concave (SCM smob)
          == Stem::get_direction(stems[0]))
     {
       Real r1 = gh_scm2double (gap);
-      Real dy = Stem::chord_start_f (stems.top ())
-       - Stem::chord_start_f (stems[0]);
+      Real dy = Stem::chord_start_y (stems.top ())
+       - Stem::chord_start_y (stems[0]);
 
       
       Real slope = dy / (stems.size () - 1);
       
-      Real y0 = Stem::chord_start_f (stems[0]);
+      Real y0 = Stem::chord_start_y (stems[0]);
       for (int i = 1; i < stems.size () - 1; i++)
        {
-         Real c = (Stem::chord_start_f (stems[i]) - y0) - i * slope;
+         Real c = (Stem::chord_start_y (stems[i]) - y0) - i * slope;
          if (c > r1)
            {
              concaveness1 = true;
@@ -862,8 +862,8 @@ Beam::check_concave (SCM smob)
       Direction dir = Directional_element_interface::get (me);  
 
       Real concave = 0;
-      Interval iv (Stem::chord_start_f (stems[0]),
-                  Stem::chord_start_f (stems.top ()));
+      Interval iv (Stem::chord_start_y (stems[0]),
+                  Stem::chord_start_y (stems.top ()));
       
       if (iv[MAX] < iv[MIN])
        iv.swap ();
@@ -871,7 +871,7 @@ Beam::check_concave (SCM smob)
       for (int i = 1; i < stems.size () - 1; i++)
        {
          Real c = 0;
-         Real f = Stem::chord_start_f (stems[i]);
+         Real f = Stem::chord_start_y (stems[i]);
          if ((c = f - iv[MAX]) > 0)
            concave += c;
          else if ((c = f - iv[MIN]) < 0)
@@ -1080,13 +1080,14 @@ Beam::stem_beams (Grob *me, Item *here, Item *next, Item *prev, Real dydx)
   Real nw_f;
   if (!Stem::first_head (here))
     nw_f = 0;
-  else {
-    int t = Stem::type_i (here); 
+  else
+    {
+      int t = Stem::duration_log (here); 
 
-    SCM proc = me->get_grob_property ("flag-width-function");
-    SCM result = gh_call1 (proc, gh_int2scm (t));
-    nw_f = gh_scm2double (result);
-  }
+      SCM proc = me->get_grob_property ("flag-width-function");
+      SCM result = gh_call1 (proc, gh_int2scm (t));
+      nw_f = gh_scm2double (result);
+    }
 
 
   Direction dir = Directional_element_interface::get (me);
@@ -1293,7 +1294,7 @@ Beam::forced_stem_count (Grob *me)
       if (Stem::invisible_b (s))
        continue;
 
-      if (((int)Stem::chord_start_f (s)) 
+      if (((int)Stem::chord_start_y (s)) 
         && (Stem::get_direction (s) != Stem::get_default_dir (s)))
         f++;
     }
index 3c46bb5ad0471ddeb5f90e93ce64d7fd8594b91e..43e66eb4a3d83f3861946f6e4966f398b46dbd36 100644 (file)
@@ -169,9 +169,9 @@ Chord_tremolo_engraver::acknowledge_grob (Grob_info info)
          Stem::set_beaming (s, f, RIGHT);
          
          SCM d = s->get_grob_property ("direction");
-         if (Stem::type_i (s) != 1)
+         if (Stem::duration_log (s) != 1)
            {
-             int gap_i =Stem::duration_log (s) - ((Stem::type_i (s) >? 2) - 2);
+             int gap_i =Stem::duration_log (s) - ((Stem::duration_log (s) >? 2) - 2);
              beam_p_->set_grob_property ("gap", gh_int2scm (gap_i));
            }
          s->set_grob_property ("direction", d);
index 1c3b90883cff24f4478c0f9f8b54871a664fde2d..c48bade0cc5bf28097173ee153010848130a851b 100644 (file)
@@ -27,9 +27,8 @@ public:
   static Grob * support_head (Grob*) ;
   static void add_head (Grob*me, Grob*n);
   static Stem_info calc_stem_info (Grob *) ;
-  static Real chord_start_f (Grob *) ;
+  static Real chord_start_y (Grob *) ;
   static Direction get_direction (Grob*) ;
-  static int type_i (Grob *) ;
   static void set_stemend (Grob *,Real);
   static Direction get_default_dir (Grob *) ;
 
index 716bcff34b9b6dbe4ab29b8a11ce31a58a034e92..8a05cc744e40e3ef2b0207c07209003da2311c22 100644 (file)
@@ -329,7 +329,7 @@ Slur::get_attachment (Grob *me, Direction dir,
            }
          else if (str == "alongside-stem")
            {
-             o = Offset (0, Stem::chord_start_f (stem));
+             o = Offset (0, Stem::chord_start_y (stem));
              /*
                Default position is on stem X, on outer side of head Y
               */
index 4e10df16767a52b2dbb3e5dae09d7f4e716cc7d2..5af470bae5402bf3a8201ba3447c81d6556ed513 100644 (file)
@@ -21,8 +21,6 @@
   TODO:
     lengthen stem if necessary
  */
-
-
 MAKE_SCHEME_CALLBACK (Stem_tremolo,dim_callback,2);
 
 /*
@@ -49,7 +47,11 @@ Stem_tremolo::height (SCM smob, SCM ax)
   assert (a == Y_AXIS);
 
   SCM mol = me->get_uncached_molecule ();
-  return ly_interval2scm (unsmob_molecule (mol)->extent (a));
+
+  if (Molecule *m = unsmob_molecule (mol))
+    return ly_interval2scm (m->extent (a));
+  else
+    return ly_interval2scm (Interval());
 }
 
 
@@ -87,14 +89,24 @@ Stem_tremolo::brew_molecule (SCM smob)
   Molecule a (Lookup::beam (dydx, width, thick));
   a.translate (Offset (-width/2, width / 2 * dydx));
   
-  int tremolo_flags;
+  int tremolo_flags = 0;
   SCM s = me->get_grob_property ("flag-count");
   if (gh_number_p (s))
     tremolo_flags = gh_scm2int (s);
-  else
-    // huh?
-    tremolo_flags = 1;
 
+  if (!tremolo_flags)
+    {
+      programming_error ("No tremolo flags?");
+
+      me->suicide();
+      return SCM_EOL;
+    }
+
+  /*
+    Who the fuck is 0.81 ?
+
+    --hwn.
+   */
   Real interbeam = beam ? Beam::get_interbeam (beam) : 0.81;
 
   Molecule mol; 
@@ -104,27 +116,47 @@ Stem_tremolo::brew_molecule (SCM smob)
       b.translate_axis (interbeam * i, Y_AXIS);
       mol.add_molecule (b);
     }
-  if (tremolo_flags)
-    mol.translate_axis (-mol.extent (Y_AXIS).center (), Y_AXIS);
-  if (beam)
+  Direction stemdir = Stem::get_direction (stem);
+  Interval mol_ext = mol.extent (Y_AXIS);
+
+  // ugh, rather calc from Stem_tremolo_req
+  int beams_i = (beam)
+    ? (Stem::beam_count (stem, RIGHT) >? Stem::beam_count (stem, LEFT))
+    : 0;
+  
+  Real beamthickness = 0.0;
+  SCM sbt = (beam) ? beam->get_grob_property ("thickness") : SCM_EOL ;
+  if (gh_number_p (sbt))
+    {
+      beamthickness = gh_scm2double (sbt) * ss;
+    }
+
+  Real end_y
+    = Stem::stem_end_position (stem) *ss/2 
+    - stemdir * (beams_i * beamthickness
+                + ((beams_i -1) >? 0) * interbeam);
+
+  /*
+    the 0.33 ss is to compensate for the size of the note head
+   */
+  Real chord_start_y = Stem::chord_start_y (stem) +
+    0.33 * ss * stemdir;
+
+  Real padding = interbeam;
+
+  /*
+    if there is not enough space, center on remaining space,
+    else one beamspace away from stem end.
+   */
+  if (stemdir * (end_y - chord_start_y) - 2*padding - mol_ext.length ()  < 0.0)
     {
-      // ugh, rather calc from Stem_tremolo_req
-      int beams_i = Stem::beam_count (stem, RIGHT)
-       >? Stem::beam_count (stem, LEFT);
-      mol.translate (Offset (0,
-                            Stem::stem_end_position (stem) * ss / 2 - 
-                            Directional_element_interface::get (beam)
-                            * beams_i * interbeam));
+      mol.translate_axis ((end_y + chord_start_y) /2.0  - mol_ext.center (),Y_AXIS);
     }
   else
-    {  
-      /*
-       Beams should intersect one beamthickness below stem end
-      */
-      Real dy = Stem::stem_end_position (stem) * ss / 2;
-      dy -= mol.extent (Y_AXIS).length () / 2 *  Stem::get_direction (stem);
-
-      mol.translate (Offset (0, dy));
+    {
+      mol.translate_axis (end_y - stemdir * interbeam
+                         -mol_ext [stemdir]
+                         , Y_AXIS);
     }
   
   return mol.smobbed_copy ();
index 2b1ad6440a9beb249938ea20d943cfb8fd24fd99..d0efe954f8e1f8e399c286efe95444048384eef3 100644 (file)
@@ -7,6 +7,10 @@
     Jan Nieuwenhuizen <janneke@gnu.org>
 
   TODO: This is way too hairy
+
+  TODO: fix naming.
+
+  Stem-end, chord-start, etc. is all confusing naming.
 */
 
 #include <math.h>              // rint
@@ -70,7 +74,7 @@ Stem::head_positions (Grob*me)
 
 
 Real
-Stem::chord_start_f (Grob*me) 
+Stem::chord_start_y (Grob*me) 
 {
   return head_positions (me)[get_direction (me)]
     * Staff_symbol_referencer::staff_space (me)/2.0;
@@ -119,11 +123,6 @@ Stem::set_stemend (Grob*me, Real se)
   me->set_grob_property ("stem-end-position", gh_double2scm (se));
 }
 
-int
-Stem::type_i (Grob*me) 
-{
-  return first_head (me) ?  Note_head::balltype_i (first_head (me)) : 2;
-}
 
 /*
   Note head that determines hshift for upstems
@@ -296,7 +295,7 @@ Stem::get_default_stem_end_position (Grob*me)
   Real shorten_f = a[ ((duration_log (me) - 2) >? 0) <? (a.size () - 1)] * 2;
 
   /* On boundary: shorten only half */
-  if (abs (chord_start_f (me)) == 0.5)
+  if (abs (chord_start_y (me)) == 0.5)
     shorten_f *= 0.5;
 
   /* URGURGURG
@@ -311,7 +310,7 @@ Stem::get_default_stem_end_position (Grob*me)
   
   /* stems in unnatural (forced) direction should be shortened, 
     according to [Roush & Gourlay] */
-  if (chord_start_f (me)
+  if (chord_start_y (me)
       && (get_direction (me) != get_default_dir (me)))
     length_f -= shorten_f;
 
@@ -750,7 +749,7 @@ Stem::calc_stem_info (Grob*me)
 
   Real thick = gh_scm2double (beam->get_grob_property ("thickness"));
   Stem_info info; 
-  info.ideal_y = chord_start_f (me);
+  info.ideal_y = chord_start_y (me);
 
   // for simplicity, we calculate as if dir == UP
 
index abd9e1479ec0e1af98552d4372a72c3891ae7348..e06ac2b59d88c63b7bc5cebadca756adc63d2dc9 100644 (file)
@@ -143,3 +143,5 @@ chkfontpath --remove=/usr/share/lilypond/pfa/
 
 %files documentation
 %doc web/
+%doc input/
+%doc mutopia/