]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.12
authorfred <fred>
Tue, 26 Mar 2002 22:44:18 +0000 (22:44 +0000)
committerfred <fred>
Tue, 26 Mar 2002 22:44:18 +0000 (22:44 +0000)
23 files changed:
lily/beaming-info.cc [new file with mode: 0644]
lily/chord-tremolo-engraver.cc
lily/clef-engraver.cc
lily/clef-item.cc
lily/include/beam.hh
lily/include/bow.hh
lily/include/clef-item.hh
lily/include/lily-guile.hh
lily/include/note-head.hh
lily/include/staff-symbol-referencer.hh
lily/include/stem.hh
lily/lily-guile.cc
lily/misc.cc
lily/note-column.cc
lily/note-head.cc
lily/slur.cc
lily/staff-symbol-referencer.cc
lily/stem-engraver.cc
lily/stem-tremolo.cc
lily/stem.cc
lily/tie.cc
scm/generic-property.scm
scm/lily.scm

diff --git a/lily/beaming-info.cc b/lily/beaming-info.cc
new file mode 100644 (file)
index 0000000..ef0bb29
--- /dev/null
@@ -0,0 +1,97 @@
+/*   
+     beaming-info.cc --  implement Beaming_info, Beaming_info_list
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  
+ */
+
+#include "beaming.hh"
+
+Beaming_info::Beaming_info( )
+{
+  start_mom_ = 0;
+  beams_i_drul_[LEFT] = 0;
+  beams_i_drul_[RIGHT] = 0;  
+}
+
+Beaming_info::Beaming_info(Moment m, int i)
+{
+  start_mom_ = m;
+  beams_i_drul_[LEFT] = i;
+  beams_i_drul_[RIGHT] = i;  
+}
+
+const int infinity_i = 1000;   // guh.
+
+int
+Beaming_info_list::min_denominator_index () const
+{
+  int minden = infinity_i;
+  int minidx = -1;
+
+  for (int i=1; i < infos_.size ( ); i++)
+    {
+      if (infos_[i].start_mom_.den_i () < minden)
+       {
+         minidx = i;
+         minden = infos_[i].start_mom_.den_i  ();
+       }
+    }
+
+  return minidx;
+}
+
+int
+Beaming_info_list::beam_extend_count (Direction d) const
+{
+  if (infos_.size () == 1)
+    return infos_[0].beams_i_drul_[d];
+
+  Beaming_info thisbeam  = infos_.boundary (d, 0);
+  Beaming_info next  = infos_.boundary (d, 1);
+  
+  return thisbeam.beams_i_drul_[-d] <? next.beams_i_drul_[d];
+}
+
+void
+Beaming_info_list::beamify ()
+{
+  if (infos_.size () <= 1)
+    return;
+      
+  Drul_array<Beaming_info_list> splits;
+  int m = min_denominator_index ();
+  splits[LEFT].infos_ = infos_.slice (0,m);
+  splits[RIGHT].infos_ = infos_.slice (m, infos_.size ());
+
+  Direction d = LEFT;
+  do
+    {
+      splits[d].beamify ();
+    }
+  while (flip (&d) != LEFT);
+
+  int middle_beams = splits[RIGHT].beam_extend_count (LEFT) <?
+    splits[LEFT].beam_extend_count (RIGHT);
+
+  do
+    {
+      if (splits[d].infos_.size () != 1)
+       {
+         splits[d].infos_.boundary (-d, 0).beams_i_drul_[-d] = middle_beams;
+       }
+    }
+  while (flip (&d) != LEFT);
+
+  infos_ = splits[LEFT].infos_;
+  infos_.concat (splits[RIGHT].infos_);
+}
+
+void
+Beaming_info_list::add_stem (Moment m, int b)
+{
+  infos_.push  (Beaming_info (m, b));
+}
index c705ea05a36805686634b97ab671b03e0d04d2a7..6c9f9e2bc890c88a137c26d72b1a3ead8be4f69e 100644 (file)
@@ -139,13 +139,10 @@ Chord_tremolo_engraver::acknowledge_element (Score_element_info i)
          int type_i = prev_start_req_->type_i_;
          s->set_elt_property ("duration-log",  gh_int2scm (intlog2 (type_i) - 2));
 
-         s->beams_i_drul_[LEFT] = s->flag_i ();
-         s->beams_i_drul_[RIGHT] = s->flag_i ();
+         s->set_beaming (s->flag_i (), LEFT);
+         s->set_beaming ( s->flag_i (), RIGHT);
          
-         abeam_p_->multiplicity_i_ = s->flag_i ();
-         /*
-           abbrev gaps on all but half note
-         */
+
 #if 0
          if (s->type_i () != 1)
            {
index 226e7adaa4785249eee5957cd010dcf14e489892..5de0c8e5495bce25e17f9853bb2e24c14567a73b 100644 (file)
@@ -178,6 +178,7 @@ Clef_engraver::create_clef()
   if (!clef_p_)
     {
       Clef_item *c= new Clef_item;
+      c->set_elt_property ("breakable", SCM_BOOL_T);
       c->set_elt_property ("break-aligned", SCM_BOOL_T);
       announce_element (Score_element_info (c, clef_req_l_));
 
index c98c188f7cc4c09da9d5e33c34462832d8e1d861..644735e28822797a5cb91e2602bbbaf367a4770b 100644 (file)
@@ -22,12 +22,13 @@ Clef_item::do_pre_processing()
 {
   SCM style_sym =get_elt_property ("style");
   String style;
-  if (style_sym != SCM_UNDEFINED)
+  if (gh_string_p (style_sym))
     style = ly_scm2string (style_sym);
   
   if (break_status_dir() != RIGHT && style != "fullSizeChanges")
     symbol_ += "_change";
-  if (style == "transparent")
+  
+  if (style == "transparent")  // UGH. JUNKME
     {
       set_elt_property ("transparent", SCM_BOOL_T);
       set_empty (X_AXIS);
@@ -35,12 +36,10 @@ Clef_item::do_pre_processing()
 }
 
 /*
-  FIXME
+  JUNKME
 */
 Clef_item::Clef_item()
 {
-  set_elt_property ("breakable", SCM_BOOL_T);
-
   symbol_ = "treble";
 }
 
index d3d3c71afd089c50f6567e5a5270393a4226f70c..ff53282f52661eaf11fa9b0d8e2507c15a89f6e7 100644 (file)
@@ -14,7 +14,7 @@
 /** a beam connects multiple stems.
 
   Beam adjusts the stems its owns to make sure that they reach the
-  beam and that point in the correct direction
+  beam and that point in the correct direction (urg?)
 
 elt property:
 
@@ -25,7 +25,8 @@ should beam slope be damped? 0: no, 1: yes, 100000: horizontal beams
 slope_quantisation: 'none, 'normal or 'traditional
 
 */
-class Beam : public Directional_spanner  {
+class Beam : public Directional_spanner
+{
 public:
 
   int stem_count () const;
@@ -36,51 +37,44 @@ public:
   Stem* last_visible_stem () const;
 
   /**
-     the slope of the beam in (staffpositions) per (X-dimension, in PT).
-     UGH. standardise this for once and for all.
+     the slope of the beam in dy/dx
    */
-  Real slope_f_;
+  Real dydx_f_;
 
   /// position of leftmost end of beam  
   Real left_y_;
 
-  /** 
-    highest number of beams present, for opening-up of beam-spacing
-    and calculation of stem lengths
-   */
-  int multiplicity_i_;
-
   Beam ();
   void add_stem (Stem*);
-
   void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current);
   void set_beaming (Beaming_info_list *);
   void set_stemlens ();
   VIRTUAL_COPY_CONS(Score_element);
 
+  int get_multiplicity () const;
+
 protected:
-  Offset center () const;
-  Direction get_default_dir () const;
-  void set_direction (Direction);
-  void set_stem_shorten ();
-  bool auto_knee (SCM gap, bool interstaff_b);
-  bool auto_knees ();
-  
   virtual void do_pre_processing ();
   virtual void do_post_processing ();
-  virtual void do_add_processing ();
-  virtual void do_print() const;
   virtual Molecule*do_brew_molecule_p () const;
 
   Molecule stem_beams (Stem *here, Stem *next, Stem *prev) const;
-
 private:
-  void calculate_slope ();
-  Real check_stemlengths_f (bool set_b);
-  void solve_slope ();
-
-  void quantise_left_y (bool extend_b);
-  void quantise_dy ();
+  Direction calc_default_dir () const;
+  void set_stem_directions ();
+  void auto_knees ();
+  bool auto_knee (String gap_str, bool interstaff_b);
+  void set_stem_shorten ();
+  void calc_position_and_height (Real* y, Real* dy) const;
+  bool suspect_slope_b (Real y, Real dy) const;
+  Real calc_slope_damping_f (Real dy) const;
+  Real calc_stem_y_f (Stem* s, Real y, Real dy) const;
+  Real check_stem_length_f (Real y, Real dy) const;
+  void set_stem_length (Real y, Real dy);
+  Real quantise_dy_f (Real dy) const;
+  Real quantise_y_f (Real y, Real dy, int quant_dir);
+  int forced_stem_count () const;
 
 };
 
index da2e7a3f1dde7273dee23b66f49a1bde966d9635..132ae263a69141fffb6e252a4624382e54ea3cf3 100644 (file)
@@ -30,7 +30,6 @@ public:
 
 protected:
   virtual Molecule* do_brew_molecule_p () const;
-  //  virtual Interval do_width () const;    
   Array<Offset> get_controls () const;
   virtual Array<Offset> get_encompass_offset_arr () const;
   static Interval dim_callback (Dimension_cache const*);
index e35b20c9c0f10df922c2fe78165ec363eae43f0b..68ed2dc5e274c54fe60c8ff6430b3eefcd247b6c 100644 (file)
@@ -30,7 +30,6 @@ protected:
   virtual Molecule* do_brew_molecule_p() const;
   virtual void do_add_processing ();
 public:
-  
   String symbol_;
 
   VIRTUAL_COPY_CONS(Score_element);
index ddb21f4c5ce844e71256f37dea57f1f2710879d6..84af73262bfa92093c2ac9477b85ba08cd353dcc 100644 (file)
@@ -44,7 +44,7 @@ void init_ly_protection ();
 unsigned int ly_scm_hash (SCM s);
 
 SCM index_cell (SCM cellp, Direction d);
-
+SCM index_set_cell (SCM cellp, Direction d, SCM val);
 
 /*
   snarfing.
index bbc051d2396ac6f1096a0540f55338e5d3da5fba..d08b85143dd6ce05b7c72af0fc4c8536a184359c 100644 (file)
 class Note_head : public Rhythmic_head
 {
 public:
-  Note_head ();
-  void flip_around_stem (Direction);
   static int compare (Note_head * const &a, Note_head *const &b) ;
 protected:
-  Molecule make_molecule () const;
   
-  static  Interval dim_callback (Dimension_cache const*);
   virtual void do_pre_processing();
   virtual Molecule* do_brew_molecule_p() const;
 };
index 60e9ac27870c78a2a4d71bacf40d27b04c8911b7..a9cb5056cd2a45f53dbd7e917984db1d747460e7 100644 (file)
@@ -12,6 +12,7 @@
 
 #include "score-element.hh"
 
+
 /**
    A notation object that needs access to variables of the staff (no
    lines, leading).
@@ -38,6 +39,8 @@ public:
   Real position_f () const;
 };
 
+int compare_position (Score_element *const&,Score_element *const&); 
+
 
 Staff_symbol_referencer_interface staff_symbol_referencer_interface  (Score_element const*);
 
index a40484123c159980c75c226d50c0862bbe5e9814..7da90a36493009e90690d4a1ab0b6d3943364217 100644 (file)
@@ -54,17 +54,16 @@ public:
   /// log of the duration. Eg. 4 -> 16th note -> 2 flags
   int flag_i () const;
 
-  Drul_array<int> beams_i_drul_;
-
-
+  int beam_count (Direction) const;
+  void set_beaming (int,  Direction d);
   /** 
     don't print flag when in beam.
     our beam, for aligning abbrev flags
    */
   Beam* beam_l () const;
   Note_head * first_head () const;
+  Score_element * support_head () const;
   Stem ();
-    
   /// ensure that this Stem also encompasses the Notehead #n#
   void add_head (Rhythmic_head*n);
 
@@ -83,7 +82,6 @@ public:
   void set_default_extents();
   void set_noteheads();
 
-  Real stem_length_f() const;
   Real stem_end_f() const;
   Real stem_begin_f() const;
   Real note_delta_f () const;
index 20abc957b45668b481d6817892cb44547dfcfc74..93e1651cc0a4ad55cdc736d51e27902377aab84c 100644 (file)
@@ -187,6 +187,15 @@ index_cell (SCM s, Direction d)
   return (d == LEFT) ? SCM_CAR (s) : SCM_CDR (s);
 }
 
+SCM
+index_set_cell (SCM s, Direction d, SCM v)
+{
+  if (d == LEFT)
+    gh_set_car_x (s, v);
+  else if (d == RIGHT)
+    gh_set_cdr_x (s, v);
+  return s;
+}
   
 SCM
 array_to_list (SCM *a , int l)
index 3f1f2ad949fb052023c6a682e44e1a3cc4bf1d3a..ab6cceb5f55310b13d0ed221ec6e3d3c3b60cbef 100644 (file)
@@ -32,23 +32,6 @@ log_2(double x) {
   return log (x)  /log (2.0);
 }
 
-#ifndef STANDALONE
-Interval
-itemlist_width (const Array<Item*> &its)
-{
-  Interval iv ;
-  iv.set_empty();
-   
-  for (int j =0; j < its.size(); j++)
-    {
-       iv.unite (its[j]->extent (X_AXIS));
-
-    }
-  return iv;
-}
-
-#endif
-
 
 /*
   TODO
index 439cb08186489148f0122f2f96e2a8ae27a1b7b2..7ed9936d149ea28b56f03432600942683d5c0a03 100644 (file)
@@ -156,11 +156,26 @@ Note_column::do_post_processing ()
   if (!b || !b->stem_count ())
     return;
   
-  /* ugh. Should be done by beam. */
+  /* ugh. Should be done by beam.
+     (what? should be done --jcn)
+    scary too?: height is calculated during post_processing
+   */
+  Real dy = 0;
+  Real y = 0;
+  SCM s = b->get_elt_property ("height");
+  if (s != SCM_UNDEFINED)
+    dy = gh_scm2double (s);
+    s = b->get_elt_property ("y-position");
+  if (s != SCM_UNDEFINED)
+    y = gh_scm2double (s);
+
+  Real x0 = b->first_visible_stem ()->hpos_f ();
+  Real dydx = b->last_visible_stem ()->hpos_f () - x0;
+
   Direction d = stem_l ()->get_direction ();
-  Real beamy = (stem_l ()->hpos_f () - b->stem(0)->hpos_f ()) * b->slope_f_ + b->left_y_;
+  Real beamy = (stem_l ()->hpos_f () - x0) * dydx + y;
 
-  SCM s = get_elt_property ("rests");
+  s = get_elt_property ("rests");
   Score_element * se = unsmob_element (gh_car (s));
   Staff_symbol_referencer_interface si (se);
 
index 4ddaac08487a9e3cb95d3b741c2bf651c2a1f342..ae8ec870454d32cb9434228b5685ae7e825474c2 100644 (file)
 #include "dimension-cache.hh"
 #include "staff-symbol-referencer.hh"
 
-void
-Note_head::flip_around_stem (Direction d)
-{
-  Real l= make_molecule ().dim_[X_AXIS].length ();
-  translate_axis (l * d, X_AXIS);
-}
 
-Interval
-Note_head::dim_callback (Dimension_cache const * c)
-{
-  Note_head* n = dynamic_cast<Note_head*> (c->element_l ());
-  return n->make_molecule ().dim_[X_AXIS];
-}
 
-Note_head::Note_head ()
-{
-  dim_cache_[X_AXIS]->callback_l_ = dim_callback;
-}
 
 void
 Note_head::do_pre_processing ()
@@ -41,7 +25,7 @@ Note_head::do_pre_processing ()
   // 8 ball looks the same as 4 ball:
   String type; 
   SCM style  = get_elt_property ("style");
-  if (style != SCM_UNDEFINED)
+  if (gh_string_p (style))
     {
       type = ly_scm2string (style);
     }
@@ -60,28 +44,8 @@ Note_head::do_pre_processing ()
     }
 }
 
-int
-Note_head::compare (Note_head *const  &a, Note_head * const &b)
-{
-  Staff_symbol_referencer_interface s1(a);
-  Staff_symbol_referencer_interface s2(b);      
 
-  return sign(s1.position_f () - s2.position_f ());
-}
 
-Molecule
-Note_head::make_molecule () const
-{
-  String type; 
-  SCM style  = get_elt_property ("style");
-  if (style != SCM_UNDEFINED)
-    {
-      type = ly_scm2string (style);
-    }
-  
-  return lookup_l()->afm_find (String ("noteheads-")
-                              + to_str (balltype_i ()) + type);
-}
 
 Molecule*
 Note_head::do_brew_molecule_p() const 
@@ -95,9 +59,17 @@ Note_head::do_brew_molecule_p() const
     ? 0
     : (abs((int)p) - sz) /2;
 
-  Molecule*  out =  new Molecule (make_molecule ());
+ String type; 
+  SCM style  = get_elt_property ("style");
+  if (style != SCM_UNDEFINED)
+    {
+      type = ly_scm2string (style);
+    }
+  
+  Molecule*  out =
+    new Molecule (lookup_l()->afm_find (String ("noteheads-") + to_str (balltype_i ()) + type));
 
-  Box b = out->dim_;
+  Box ledgerless = out->dim_;
 
   if (streepjes_i) 
     {
@@ -120,7 +92,7 @@ Note_head::do_brew_molecule_p() const
        }
     }
 
-  out->dim_ = b;
+  out->dim_ = ledgerless;
   return out;
 }
 
index aff1365a279f495c4f5382ee346035b3d1f0734a..0a351dc2c23f23a3de36e59ffe12ca2d798a2fcd 100644 (file)
@@ -180,7 +180,7 @@ Slur::do_post_processing ()
          if ((stem_l->extent (Y_AXIS).empty_b ()
               || !((stem_l->get_direction () == get_direction ()) && (get_direction () != d)))
              && !((get_direction () == stem_l->get_direction ())
-                  && stem_l->beam_l () && (stem_l->beams_i_drul_[-d] >= 1)))
+                  && stem_l->beam_l () && (stem_l->beam_count (-d) >= 1)))
            {
              dx_f_drul_[d] = spanned_drul_[d]->extent (X_AXIS).length () / 2;
              dx_f_drul_[d] -= d * x_gap_f;
@@ -206,7 +206,7 @@ Slur::do_post_processing ()
              /*
                side attached to beamed stem
               */
-             if (stem_l->beam_l () && (stem_l->beams_i_drul_[-d] >= 1))
+             if (stem_l->beam_l () && (stem_l->beam_count (-d) >= 1))
                {
                  dy_f_drul_[d] = stem_l->extent (Y_AXIS)[get_direction ()];
                  dy_f_drul_[d] += get_direction () * 2 * y_gap_f;
index 8bd451109a9f864ffd326ccebe1311899f6ce7fa..64a46b81170a231df59025f876e80ec34235f27d 100644 (file)
@@ -65,19 +65,22 @@ Real
 Staff_symbol_referencer_interface::position_f () const
 {
   Real p =0.0;
-  SCM pos = elt_l_->get_elt_property ("staff-position");
-  if (gh_number_p (pos))
-    p = gh_scm2double (pos);
-
   Staff_symbol * st = staff_symbol_l ();
-  if (st)
+  Score_element * c = st ? elt_l_->common_refpoint (st, Y_AXIS) : 0;
+  if (st && c)
     {
-      Score_element * c = elt_l_->common_refpoint (st, Y_AXIS);
       Real y = elt_l_->relative_coordinate (c, Y_AXIS)
        - st->relative_coordinate (c, Y_AXIS);
 
       p += 2.0 * y / st->staff_line_leading_f ();
     }
+  else
+    {
+      SCM pos = elt_l_->get_elt_property ("staff-position");
+      if (gh_number_p (pos))
+       return gh_scm2double (pos);
+    }
+  
   return  p;
 }
 
@@ -134,3 +137,12 @@ staff_symbol_referencer_interface (Score_element const*e)
 {
   return e;                    // gee, I'm so smart!
 }
+
+int
+compare_position (Score_element *const  &a, Score_element * const &b)
+{
+  Staff_symbol_referencer_interface s1(a);
+  Staff_symbol_referencer_interface s2(b);      
+
+  return sign(s1.position_f () - s2.position_f ());
+}
index e6bd43c2bdd8d121ed3f18296e4fd76eeb6335dc..09e490bdff28f2bbd24217a5f3026d6300a94d78 100644 (file)
@@ -104,13 +104,13 @@ Stem_engraver::do_pre_move_processing()
       SCM prop = get_property ("stemLeftBeamCount", &which);
       if (gh_number_p(prop))
        {
-         stem_p_->beams_i_drul_[LEFT] = gh_scm2int (prop);
+         stem_p_->set_beaming (gh_scm2int (prop),LEFT);
          ((Translator_group*)which)->set_property ("stemLeftBeamCount", SCM_UNDEFINED);
        }
       prop = get_property ("stemRightBeamCount", &which);
       if (gh_number_p(prop))
        {
-         stem_p_->beams_i_drul_[RIGHT] = gh_scm2int (prop);
+         stem_p_->set_beaming (gh_scm2int (prop), RIGHT);
          ((Translator_group*)which)->set_property ("stemRightBeamCount", SCM_UNDEFINED);
        }
 
index 069ef6259cf2d6251b527eddfc545cab309cd94a..700a491854e5410cff2a20177f142a08cb7cb6f7 100644 (file)
@@ -55,7 +55,7 @@ Stem_tremolo::do_brew_molecule_p () const
   int mult =0;
   if (Beam * b = st->beam_l ())
     {
-      mult = b->multiplicity_i_;
+      mult = b->get_multiplicity ();
     }
   
   Real interbeam_f = paper_l ()->interbeam_f (mult);
@@ -65,16 +65,25 @@ Stem_tremolo::do_brew_molecule_p () const
   Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));
 
   int beams_i = 0;
-  Real slope_f = 0.25;
-
-  if (st && st->beam_l ()) {
-    slope_f = st->beam_l ()->slope_f_;
-    // ugh, rather calc from Stem_tremolo_req
-    beams_i = st->beams_i_drul_[RIGHT] >? st->beams_i_drul_[LEFT];
-  } 
+  Real dydx = 0.25;
+  
+  if (st && st->beam_l ())
+    {
+      Real dy = 0;
+      SCM s = st->beam_l ()->get_elt_property ("height");
+      if (s != SCM_UNDEFINED)
+       dy = gh_scm2double (s);
+      Real dx = st->beam_l ()->last_visible_stem ()->hpos_f ()
+       - st->beam_l ()->first_visible_stem ()->hpos_f ();
+      dydx = dy/dx;
+  
+      // ugh, rather calc from Stem_tremolo_req
+      beams_i = st->beam_count(RIGHT) >? st->beam_count (LEFT);
+    } 
 
-  Molecule a (lookup_l ()->beam (slope_f, w, beam_f));
-  a.translate (Offset (-w/2, w / 2 * slope_f));
+  Molecule a (lookup_l ()->beam (dydx, w, beam_f));
+  a.translate (Offset (-w/2, w / 2 * dydx));
+  
 
   Molecule *beams= new Molecule; 
   for (int i = 0; i < abbrev_flags_i_; i++)
index a6ca3d3df5d3d08c4bbd769b604f666faedb3a72..232caf5aed7ac5caddd77103835aa5f983d725f4 100644 (file)
@@ -8,6 +8,7 @@
 
   TODO: This is way too hairy
 */
+
 #include "dimension-cache.hh"
 #include "stem.hh"
 #include "debug.hh"
 #include "cross-staff.hh"
 #include "staff-symbol-referencer.hh"
 
-Stem::Stem ()
+
+void
+Stem::set_beaming (int i,  Direction d )
+{
+  SCM pair = get_elt_property ("beaming");
+  
+  if (!gh_pair_p (pair))
+    {
+      pair = gh_cons (gh_int2scm (0),gh_int2scm (0));
+      set_elt_property ("beaming", pair);
+    }
+  index_set_cell (pair, d, gh_int2scm (i));
+}
+
+int
+Stem::beam_count (Direction d) const
 {
-  beams_i_drul_[LEFT] = beams_i_drul_[RIGHT] = -1;
+  SCM p=get_elt_property ("beaming");
+  if (gh_pair_p (p))
+    return gh_scm2int (index_cell (p,d));
+  else
+    return 0;
 }
 
 Interval_t<int>
@@ -55,13 +75,6 @@ Stem::head_positions () const
   return r;
 }
 
-
-Real
-Stem::stem_length_f () const
-{
-  return yextent_.length();
-}
-
 Real
 Stem::stem_begin_f () const
 {
@@ -96,19 +109,50 @@ Stem::set_stemend (Real se)
 int
 Stem::type_i () const
 {
-  return first_head ()->balltype_i ();
+  return first_head () ?  first_head ()->balltype_i () : 2;
 }
 
+
+
+/*
+  Note head that determines hshift for upstems
+ */ 
+Score_element*
+Stem::support_head ()const
+{
+  SCM h = get_elt_property ("support-head");
+  Score_element * nh = unsmob_element (h);
+  if (nh)
+    return nh;
+  else
+    return first_head ();
+}
+
+
+/*
+  The note head which forms one end of the stem.  
+ */
 Note_head*
 Stem::first_head () const
 {
-  SCM h =get_elt_property ("heads");
-  if (!gh_pair_p (h))
-    return 0;
+  const int inf = 1000000;
+  int pos = -inf;              
+  Direction dir = get_direction ();
+
 
-  Score_element * sc = unsmob_element (gh_car (h));
+  Note_head *nh =0;
+  for (SCM s = get_elt_property ("heads"); gh_pair_p (s); s = gh_cdr (s))
+    {
+      Note_head * n = dynamic_cast<Note_head*> (unsmob_element (gh_car (s)));
+      Staff_symbol_referencer_interface si (n);
+      int p = dir * int(si.position_f ());
+      if (p > pos)
+       {
+         nh = n;
+       }
+    }
 
-  return dynamic_cast<Note_head*> (sc);
+  return nh;
 }
 
 void
@@ -127,6 +171,12 @@ Stem::add_head (Rhythmic_head *n)
   gi.add_element (n);
 }
 
+Stem::Stem ()
+{
+  set_elt_property ("heads", SCM_EOL);
+  set_elt_property ("rests", SCM_EOL);
+}
+
 bool
 Stem::invisible_b () const
 {
@@ -170,6 +220,9 @@ Stem::set_default_stemlen ()
 
   Real shorten_f = paper_l ()->get_var (type_str + "forced_stem_shorten0");
 
+  /* URGURGURG
+     'set-default-stemlen' sets direction too
+   */ 
   if (!get_direction ())
     set_direction (get_default_dir ());
 
@@ -205,9 +258,8 @@ Stem::flag_i () const
 void
 Stem::set_default_extents ()
 {
-  if (!stem_length_f ())
+  if (yextent_.empty_b ())
     set_default_stemlen ();
-
 }
 
 void
@@ -215,35 +267,42 @@ Stem::set_noteheads ()
 {
   if (!first_head ())
     return;
+  
+  Link_array<Score_element> heads =
+    Group_interface__extract_elements (this, (Score_element*)0, "heads");
 
+  heads.sort (compare_position);
+  Direction dir =get_direction ();
   
-  Link_array<Note_head> head_l_arr =
-    Group_interface__extract_elements (this, (Note_head*)0, "heads");
+  if (dir < 0)
+    heads.reverse ();
 
-  head_l_arr.sort (Note_head::compare);
-  if (get_direction () < 0)
-    head_l_arr.reverse ();
 
-  Note_head * beginhead =   first_head ();
-  beginhead->set_elt_property ("extremal", SCM_BOOL_T);
-  if  (beginhead !=   head_l_arr.top ())
-    head_l_arr.top ()->set_elt_property ("extremal", SCM_BOOL_T);
+  Real w = support_head ()->extent (X_AXIS)[dir];
+  for (int i=0; i < heads.size (); i++)
+    {
+      heads[i]->translate_axis (w - heads[i]->extent (X_AXIS)[dir], X_AXIS);
+    }
   
-  int parity=1;
-  int lastpos = int (Staff_symbol_referencer_interface (beginhead).position_f ());
-  for (int i=1; i < head_l_arr.size (); i ++)
+  bool parity= true;
+  int lastpos = int (Staff_symbol_referencer_interface (heads[0]).position_f ());
+  for (int i=1; i < heads.size (); i ++)
     {
-      Real p = Staff_symbol_referencer_interface (head_l_arr[i]).position_f ();
+      Real p = Staff_symbol_referencer_interface (heads[i]).position_f ();
       int dy =abs (lastpos- (int)p);
 
       if (dy <= 1)
        {
          if (parity)
-           head_l_arr[i]->flip_around_stem (get_direction ());
+           {
+             Real l  = heads[i]->extent (X_AXIS).length ();
+             heads[i]->translate_axis (l * get_direction (), X_AXIS);
+           }
          parity = !parity;
        }
       else
-       parity = 1;
+       parity = true;
+      
       lastpos = int (p);
     }
 }
@@ -262,7 +321,6 @@ Stem::do_pre_processing ()
       set_empty (X_AXIS);      
     }
 
-
   set_spacing_hints ();
 }
 
@@ -329,8 +387,6 @@ Stem::dim_callback (Dimension_cache const* c)
 }
 
 
-
-
 const Real ANGLE = 20* (2.0*M_PI/360.0); // ugh!
 
 Molecule*
@@ -342,8 +398,8 @@ Stem::do_brew_molecule_p () const
     .staff_line_leading_f ()/2.0;
 
   Real head_wid = 0;
-  if (first_head ())
-    head_wid = first_head ()->extent (X_AXIS).length ();
+  if (support_head ())
+    head_wid = support_head ()->extent (X_AXIS).length ();
   stem_y[Direction(-get_direction ())] += get_direction () * head_wid * tan(ANGLE)/(2*dy);
   
   if (!invisible_b ())
@@ -354,8 +410,7 @@ Stem::do_brew_molecule_p () const
       mol_p->add_molecule (ss);
     }
 
-  if (get_elt_property ("beam") == SCM_UNDEFINED
-      && abs (flag_i ()) > 2)
+  if (!beam_l () && abs (flag_i ()) > 2)
     {
       Molecule fl = flag ();
       fl.translate_axis(stem_y[get_direction ()]*dy, Y_AXIS);
@@ -402,29 +457,23 @@ Stem::beam_l ()const
 }
 
 
+// ugh still very long.
 Stem_info
 Stem::calc_stem_info () const
 {
   assert (beam_l ());
 
-  SCM bd = get_elt_property ("beam-dir");
-  Real internote_f
-    = staff_symbol_referencer_interface (this).staff_line_leading_f ()/2;
-  
-  Direction beam_dir;
-  Stem_info info; 
-
-  if (isdir_b (bd))
+  Direction beam_dir = beam_l ()->get_direction ();
+  if (!beam_dir)
     {
-      beam_dir = to_dir (bd);
+      programming_error ("Beam dir not set.");
+      beam_dir = UP;
     }
-  else
-    {
-      programming_error ("Beam direction not set."); 
-      beam_dir = UP;           //  GURAUGRNAGURAGU! urg !
-    }
-  
-  Real interbeam_f = paper_l ()->interbeam_f (beam_l ()->multiplicity_i_);
+    
+  Stem_info info; 
+  Real internote_f
+     = staff_symbol_referencer_interface (this).staff_line_leading_f ()/2;
+   Real interbeam_f = paper_l ()->interbeam_f (beam_l ()->get_multiplicity ());
   Real beam_f = gh_scm2double (beam_l ()->get_elt_property ("beam-thickness"));
          
   info.idealy_f_ = chord_start_f ();
@@ -438,17 +487,17 @@ Stem::calc_stem_info () const
   int stem_max = (int)rint(paper_l ()->get_var ("stem_max"));
   String type_str = grace_b ? "grace_" : "";
   Real min_stem_f = paper_l ()->get_var (type_str + "minimum_stem_length"
-    + to_str (beam_l ()->multiplicity_i_ <? stem_max)) * internote_f;
+    + to_str (beam_l ()->get_multiplicity () <? stem_max)) * internote_f;
   Real stem_f = paper_l ()->get_var (type_str + "stem_length"
-    + to_str (beam_l ()->multiplicity_i_ <? stem_max)) * internote_f;
+    + to_str (beam_l ()->get_multiplicity () <? stem_max)) * internote_f;
 
   if (!beam_dir || (beam_dir == get_direction ()))
     /* normal beamed stem */
     {
-      if (beam_l ()->multiplicity_i_)
+      if (beam_l ()->get_multiplicity ())
        {
          info.idealy_f_ += beam_f;
-         info.idealy_f_ += (beam_l ()->multiplicity_i_ - 1) * interbeam_f;
+         info.idealy_f_ += (beam_l ()->get_multiplicity () - 1) * interbeam_f;
        }
       info.miny_f_ = info.idealy_f_;
       info.maxy_f_ = INT_MAX;
@@ -472,7 +521,7 @@ Stem::calc_stem_info () const
          info.miny_f_ = info.miny_f_ >? 0;
          //lowest beam of (UP) beam must never be lower than second staffline
          info.miny_f_ = info.miny_f_ >? (- 2 * internote_f - beam_f
-                               + (beam_l ()->multiplicity_i_ > 0) * beam_f + interbeam_f * (beam_l ()->multiplicity_i_ - 1));
+                               + (beam_l ()->get_multiplicity () > 0) * beam_f + interbeam_f * (beam_l ()->get_multiplicity () - 1));
        }
     }
   else
@@ -490,11 +539,12 @@ Stem::calc_stem_info () const
   info.idealy_f_ = info.miny_f_ >? info.idealy_f_;
 
   Real interstaff_f = calc_interstaff_dist (this, beam_l ());
-  info.idealy_f_ += interstaff_f * beam_dir;
 
-  SCM s = get_elt_property ("shorten");
+  SCM s = beam_l ()->get_elt_property ("shorten");
   if (s != SCM_UNDEFINED)
     info.idealy_f_ -= gh_double2scm (s);
+
+  info.idealy_f_ += interstaff_f * beam_dir;
   info.miny_f_ += interstaff_f * beam_dir;
   info.maxy_f_ += interstaff_f * beam_dir;
 
index f7ea46e8015040c79617a4f319e6e990ddad5082..c891d0bb685a14cfede797791b592203173c6ddc 100644 (file)
@@ -17,13 +17,9 @@ void
 Tie::set_head (Direction d, Note_head * head_l)
 {
   assert (!head (d));
-  if (d == LEFT)
-    gh_set_car_x (get_elt_property ("heads"), head_l->self_scm_ );
-  else if (d == RIGHT)
-    gh_set_cdr_x (get_elt_property ("heads"), head_l->self_scm_ );
+  index_set_cell (get_elt_property ("heads"), d, head_l->self_scm_);
   
   set_bounds (d, head_l);
-
   add_dependency (head_l);
 }
 
@@ -76,8 +72,9 @@ Tie::do_add_processing()
       new_head_drul[d] = head((Direction)-d);
   } while (flip(&d) != LEFT);
 
-  gh_set_car_x (get_elt_property ("heads"), new_head_drul[LEFT]->self_scm_ );
-  gh_set_cdr_x (get_elt_property ("heads"), new_head_drul[RIGHT]->self_scm_ );
+  index_set_cell (get_elt_property ("heads"), LEFT, new_head_drul[LEFT]->self_scm_ );
+  index_set_cell (get_elt_property ("heads"), RIGHT, new_head_drul[LEFT]->self_scm_ );
+
 }
 
 void
index 867d71e6248bb46e579dcde3a834254228f08dca..c6104e21d7c2e3c5f6cb1c399ebb0884934a47b4 100644 (file)
@@ -7,6 +7,8 @@
         (list 'autoInterstaffKneeGap number? 'auto-interstaff-knee-gap)
         (list 'beamQuantisation symbol? 'slope-quantisation)
         (list 'beamDirAlgorithm symbol? 'beam-dir-algorithm)
+        (list 'beamSlope number? 'height)
+        (list 'beamVerticalPosition number? 'y-position)
         )
        )
   )
@@ -20,6 +22,7 @@
         (list 'stemLength number? 'length)
         (list 'stemStyle string? 'style)
         (list 'noStemExtend boolean? 'no-stem-extend)
+        (list 'stemShorten number? 'shorten)
         ))
   )
 
index 34a370175d6d0c82ae6b5c608c1a4d76b2f723d1..ce8c9eec87cfed6aaaebd5ba314fbecce86af2a1 100644 (file)
 ;;
 ;;
 
+;; (Measured in interlines? -- jcn)
 (define space-alist
  '(
    (("" "Clef_item") . (minimum-space 1.0))
        (begin (ly-warn (string-append "Unknown spacing pair `" this "', `" next "'"))
               '(minimum-space 0.0)))))
   
-       
+
+;; Measured in interlines (urg: how to say #interline?)
+(define (stem-shorten flags) 0.5)
+(define (beamed-stem-shorten multiplicity) 0.5)
+
 
 ;;;;;;;; TeX