]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.1.27.jcn2: hat
authorJan Nieuwenhuizen <janneke@gnu.org>
Sat, 6 Feb 1999 16:09:10 +0000 (17:09 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Sat, 6 Feb 1999 16:09:10 +0000 (17:09 +0100)
pl 27.jcn2
- grand renaming: Duration vs Moment / Rational

55 files changed:
NEWS
VERSION
lib/duration-convert.cc
lib/duration.cc
lib/include/duration.hh
lily/auto-beam-engraver.cc
lily/bar-engraver.cc
lily/bar-number-engraver.cc
lily/beam-engraver.cc
lily/beam.cc
lily/command-request.cc
lily/global-translator.cc
lily/grouping.cc
lily/include/command-request.hh
lily/include/global-translator.hh
lily/include/grouping.hh
lily/include/midi-def.hh
lily/include/midi-item.hh
lily/include/music-list.hh
lily/include/music-wrapper.hh
lily/include/music.hh
lily/include/musical-request.hh
lily/include/paper-def.hh
lily/include/repeated-music.hh
lily/include/request-iterator.hh
lily/include/rhythmic-grouping.hh [new file with mode: 0644]
lily/include/time-signature-engraver.hh
lily/include/timing-translator.hh
lily/include/translator.hh
lily/midi-def.cc
lily/midi-item.cc
lily/midi-walker.cc
lily/multi-measure-rest-engraver.cc
lily/music-list.cc
lily/music-wrapper.cc
lily/music.cc
lily/musical-request.cc
lily/paper-def.cc
lily/parser.yy
lily/repeat-engraver.cc
lily/repeated-music-iterator.cc
lily/repeated-music.cc
lily/request-iterator.cc
lily/rhythmic-grouping.cc [new file with mode: 0644]
lily/score-engraver.cc
lily/score.cc
lily/sequential-music-iterator.cc
lily/spring-spacer.cc
lily/staff-margin-engraver.cc
lily/tie-engraver.cc
lily/time-description.cc
lily/timing-translator.cc
lily/translator-group.cc
lily/translator.cc
lily/tuplet-engraver.cc

diff --git a/NEWS b/NEWS
index 944aa057e11e0986b5b8be125068fbf52c59fc87..6e5bc437317e6684f32f333b8012a90166fefb00 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+pl 27.jcn2
+       - grand renaming: Duration vs Moment / Rational
+
 pl 27.jcn1
        - complete redo of chord and chord name code
        - small fixes
diff --git a/VERSION b/VERSION
index 9a0ab9447edbaaa51a0405b77e18eeb60174ca27..690b6a39317aa6cd9fb798aef2429a32908b2179 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=1
 PATCH_LEVEL=27
-MY_PATCH_LEVEL=jcn1
+MY_PATCH_LEVEL=jcn2
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
index c1240f3cddf73bd3320e56fb9a75490a53647b01..4f2e2a9015af5175870cd381bb03284d6582079a 100644 (file)
@@ -105,14 +105,14 @@ Duration_convert::mom2_dur (Moment mom)
 
   Duration dur = mom2standardised_dur (mom);
   //   if (!dur.mom () || (dur.mom () == mom))
-  if (!dur.length () || (dur.length () == mom))
+  if (!dur.length_mom () || (dur.length_mom () == mom))
     return dur;
   assert (midi_as_plet_b_s);
 
   //   dur.set_plet (type_mom, Duration::division_1_i_s / 4); 
 
   //   Moment as_plet_mom = mom / dur.mom ();
-  Moment as_plet_mom = mom / dur.length ();
+  Moment as_plet_mom = mom / dur.length_mom ();
   as_plet_mom *= dur.plet_.mom ();
   long num = as_plet_mom.num ();
   long den = as_plet_mom.den ();
@@ -185,7 +185,7 @@ Duration_convert::ticks2_dur (int ticks_i)
 
   Duration dur = mom2standardised_dur (mom);
 
-  if (dur.length () == mom)
+  if (dur.length_mom () == mom)
     return dur;
                
   return mom2_dur (mom);
index f65348ae6daa2a199124f5e49867bf42bf7ef337..8e254ba0f226555425b944268df71b92963b671a 100644 (file)
@@ -45,10 +45,8 @@ Duration::compress (Moment m)
   plet_.type_i_ *= m.den_i (); 
 }
 
-// ugh, what's this?
-// i should be called "mom ()", ... or at least "length_mom ()"
 Moment
-Duration::length () const
+Duration::length_mom () const
 {
   return Duration_convert::dur2_mom (*this);
 }
index 509a6d69d93765e96155f42d545f32cee43355cb..1ece5771d85da6a6376cb4b709a8c1f1f5184280 100644 (file)
@@ -31,7 +31,7 @@ struct Duration {
 
   static bool duration_type_b (int t);
   void set_ticks (int ticks_i );
-  Moment length () const ;     // zo naai mij
+  Moment length_mom () const ;
   static int division_1_i_s;
 
   /// Logarithm of the base duration.
index 23698891e4f0d51f17dafea2ea23bc23a77444e0..9536e17aceeaf50aa0d0eb2fc9a9914471925751 100644 (file)
@@ -11,7 +11,7 @@
 #include "musical-request.hh"
 #include "bar.hh"
 #include "beam.hh"
-#include "grouping.hh"
+#include "rhythmic-grouping.hh"
 #include "rest.hh"
 #include "stem.hh"
 #include "debug.hh"
@@ -83,7 +83,7 @@ Auto_beam_engraver::consider_end_and_begin ()
 void
 Auto_beam_engraver::begin_beam ()
 {
-  DOUT << String ("starting autobeam at: ") + now_moment ().str () + "\n";
+  DOUT << String ("starting autobeam at: ") + now_mom ().str () + "\n";
   beam_p_ = new Beam;
   grouping_p_ = new Rhythmic_grouping;
 
@@ -112,7 +112,7 @@ Auto_beam_engraver::begin_beam ()
 void
 Auto_beam_engraver::end_beam ()
 {
-  DOUT << String ("ending autobeam at: ") + now_moment ().str () + "\n";
+  DOUT << String ("ending autobeam at: ") + now_mom ().str () + "\n";
   if (beam_p_->stems_.size () < 2)
     {
       DOUT << "junking autombeam: less than two stems\n";
@@ -241,12 +241,12 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info)
              consider_end_and_begin ();
            }
          mult_i_ = m;
-         grouping_p_->add_child (start, rhythmic_req->duration ());
+         grouping_p_->add_child (start, rhythmic_req->length_mom ());
          stem_l->flag_i_ = rhythmic_req->duration_.durlog_i_;
          beam_p_->add_stem (stem_l);
-         Moment now = now_moment ();
+         Moment now = now_mom ();
          last_add_mom_ = now;
-         extend_mom_ = extend_mom_ >? now + rhythmic_req->duration ();
+         extend_mom_ = extend_mom_ >? now + rhythmic_req->length_mom ();
        }
     }
 }
@@ -276,7 +276,7 @@ Auto_beam_engraver::process_acknowledged ()
 {
   if (beam_p_)
     {
-      Moment now = now_moment ();
+      Moment now = now_mom ();
       if ((extend_mom_ < now)
          || ((extend_mom_ == now) && (last_add_mom_ != now )))
        {
index 57436ae70f2bee7ae42f3f120d3951537f952166..d81cafb29462f34783ac25d571f0d1d3423b5ac1 100644 (file)
@@ -104,7 +104,7 @@ Bar_engraver::do_process_requests()
       create_bar ();    
       bar_p_->type_str_ = bar_req_l_->type_str_;
     }
-  else if (!now_moment ())
+  else if (!now_mom ())
     {
       create_bar ();
       bar_p_->type_str_ = "";
index 7adc8dcdea11546bd76121830c06bfdba24698e5..54ef0e0c7705ca7a30e545cb3f5337e45bc3ebb0 100644 (file)
@@ -28,7 +28,7 @@ Bar_number_engraver::do_process_requests ()
   Timing_translator *timer = dynamic_cast<Timing_translator*>(tr);
   Time_description *time = &timer->time_;
 
-  if (!time->whole_in_measure_ && !time->cadenza_b_ && now_moment () > Moment (0))
+  if (!time->whole_in_measure_ && !time->cadenza_b_ && now_mom () > Moment (0))
     {
       create_items (0);
        
index ac7a02a26b2dbc1ef504bcbd977675c8ae3b187c..66a90faec75389a3345a3e0ccf7a276ee8e66bf1 100644 (file)
@@ -10,7 +10,7 @@
 #include "beam-engraver.hh"
 #include "musical-request.hh"
 #include "beam.hh"
-#include "grouping.hh"
+#include "rhythmic-grouping.hh"
 #include "stem.hh"
 #include "warn.hh"
 #include "time-description.hh"
@@ -171,7 +171,7 @@ Beam_engraver::acknowledge_element (Score_element_info info)
        if (!grouping_p_->child_fit_b (start))
          {
            String s (_ ("please fix me") + ": " 
-                     + _f ("stem at %s doesn't fit in beam", now_moment ().str ()));
+                     + _f ("stem at %s doesn't fit in beam", now_mom ().str ()));
 
            if (info.req_l_)
              info.req_l_->warning(s);
@@ -180,7 +180,7 @@ Beam_engraver::acknowledge_element (Score_element_info info)
          }
        else
          {
-           grouping_p_->add_child (start, rhythmic_req->duration ());
+           grouping_p_->add_child (start, rhythmic_req->length_mom ());
            stem_l->flag_i_ = rhythmic_req->duration_.durlog_i_;
            beam_p_->add_stem (stem_l);
          }
index 90476e1e9f4b3acaed60ffe8341a0482f199a557..0c4447664e83f79782cb80219cc4326d8ae76b52 100644 (file)
@@ -32,7 +32,7 @@
 #include "stem.hh"
 #include "paper-def.hh"
 #include "lookup.hh"
-#include "grouping.hh"
+#include "rhythmic-grouping.hh"
 
 Beam::Beam ()
 {
index 1ab0353bc558ab32d3c74da961a4e5e34e09e678..aa5b3877d79aa54b634f3c6e83dc6050866fb1ac 100644 (file)
@@ -74,7 +74,7 @@ Bar_req::Bar_req (String s)
 
 Partial_measure_req::Partial_measure_req (Moment m)
 {
-  duration_ =m;
+  length_mom_ =m;
 }
 
 bool
@@ -82,7 +82,7 @@ Partial_measure_req::do_equal_b (Request* r) const
 {
   Partial_measure_req *p = dynamic_cast <Partial_measure_req *> (r);
 
-  return p&& p->duration_ == duration_;
+  return p&& p->length_mom_ == length_mom_;
 }
 
 
@@ -133,7 +133,7 @@ Clef_change_req::Clef_change_req (String s)
 void
 Partial_measure_req::do_print() const
 {
-  DOUT << duration_;
+  DOUT << length_mom_;
 }
 
 
@@ -181,7 +181,7 @@ Tempo_req::do_equal_b (Request *r) const
 {
   Tempo_req *t = dynamic_cast <Tempo_req *> (r);
 
-  return t&& t->dur_.length()== dur_.length () && metronome_i_ == t->metronome_i_;
+  return t&& t->dur_.length_mom ()== dur_.length_mom () && metronome_i_ == t->metronome_i_;
 }
 
 
index d6785e6d052fc27a28dd3ea7b388145a9b968e75..b92a7a992ad2e4e41b2ec24da8674a095681d877 100644 (file)
@@ -47,7 +47,7 @@ Global_translator::prepare (Moment m)
 }
 
 Moment
-Global_translator::now_moment () const
+Global_translator::now_mom () const
 {
   return now_mom_;
 }
index af7d234bf4032d5ad41ae9b874cc3f1152f9c5a9..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,383 +0,0 @@
-/*
-  grouping.cc -- implement Rhythmic_grouping
-
-  source file of the GNU LilyPond music typesetter
-
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-#include "debug.hh"
-#include "grouping.hh"
-#include "interval.hh"
-
-void
-Rhythmic_grouping::init()
-{
-  interval_ = 0;
-  children.clear();     
-}
-
-void
-Rhythmic_grouping::OK() const
-{
-#ifndef NDEBUG
-  assert (bool (children.size()) != bool (interval_));
-
-  for (int i= 0; i < children.size(); i++) 
-    {
-      children[i]->OK();
-      if (i>0)
-       assert (children[i-1]->interval().right ==
-               children[i]->interval().left);
-    }
-#endif
-}
-
-Moment
-Rhythmic_grouping::length() const
-{
-  return interval().length ();
-}
-
-MInterval
-Rhythmic_grouping::interval() const
-{
-  if (interval_)
-    return *interval_;
-  else
-    return
-      MInterval (children[0]->interval().left,
-                children.top()->interval ().right);
-}
-
-void
-Rhythmic_grouping::split (Rhythmic_grouping r)
-{
-  if (interval_)
-    return ;
-  
-  r.intersect (interval());
-  split (r.intervals());
-  
-  for (int i= 0; i < children.size(); i++) 
-    {
-      if (!children[i]->interval_) 
-       {
-         Rhythmic_grouping here (r);   
-         children[i]->split (here);
-       }
-    }
-}
-
-
-Array<MInterval>
-Rhythmic_grouping::intervals()
-{
-  Array<MInterval> r;
-  if (interval_ || children.size() == 1) 
-    {
-      MInterval i (interval());
-      MInterval r1(i), r2(i);
-      r1.right = r2.left = i.center();
-      r.push (r1); r.push (r2);
-    }
-  else 
-    {
-      for (int i=0; i < children.size(); i++)
-       r.push (children[i]->interval());
-    }
-  return r;
-}
-
-void
-Rhythmic_grouping::intersect (MInterval t)
-{
-  if (interval_) 
-    {
-      interval_->intersect (t);
-      return;
-    }
-  
-  for (int i=0; i < children.size(); i++) 
-    {
-      MInterval inter = intersection (t, children[i]->interval());
-      if (inter.empty_b() || inter.length () <= Rational (0)) 
-       {
-         delete children[i];
-         children[i] =0;
-       }
-      else 
-       {
-         children[i]->intersect (t);
-       }
-    }
-  for (int i=0; i < children.size();) 
-    {
-      if (!children[i])
-       children.del (i);
-      else
-       i++;
-    }
-
-}
-
-/**
-  Put our children in branches of #this#.
-  The min and max time intervals coincide with elements of #splitpoints#
-
-  I really should be documenting what is happening here, but I find
-  that difficult, since I don't really understand what's going on here.
-
-  */
-void
-Rhythmic_grouping::split (Array<MInterval> splitpoints)
-{
-  //check on splitpoints..
-  int j = 0, i = 0, starti = 0, startj = 0;
-  
-  Array<Rhythmic_grouping*> ch;
-  while (1) 
-    {
-      if  (i >= children.size() || j >= splitpoints.size ())
-       break;
-       
-      assert (
-             children[starti]->interval().left== splitpoints[startj].left);
-      if (children[i]->interval().right < splitpoints[j].right) 
-       {
-         i ++;
-       }
-      else if (children[i]->interval().right > splitpoints[j].right) 
-       {
-         j ++;
-       }
-      else 
-       {
-
-         if (i == starti) 
-           {
-             ch.push (children[i]);
-           }
-         else 
-           {
-             Rhythmic_grouping *newchild=new Rhythmic_grouping (
-                                                                children.slice (starti, i+1));
-
-             ch.push (newchild);
-           }
-         i ++;
-         j++;
-         starti = i;
-         startj = j;
-
-
-       }
-    }
-  if (ch.size() != 1)
-    children = ch;
-}
-
-
-Rhythmic_grouping::Rhythmic_grouping (MInterval t, int n)
-{
-  init();
-  if (n == 1 || !n) 
-    {
-      interval_ = new MInterval (t);
-      return;
-    }
-  Moment dt = t.length()/Rational (n);
-  MInterval basic = MInterval (t.left, t.left+dt);
-  for (int i= 0; i < n; i++)
-    children.push (new Rhythmic_grouping (dt*Rational (i) + basic));
-}
-
-
-Rhythmic_grouping::Rhythmic_grouping (Array<Rhythmic_grouping*> r)
-  :children (r)
-{
-  interval_ =0;
-}
-
-Rhythmic_grouping::~Rhythmic_grouping()
-{
-  junk();    
-}
-
-void
-Rhythmic_grouping::copy (Rhythmic_grouping const&s)
-{
-  interval_ =  (s.interval_)? new MInterval (*s.interval_) : 0;
-  for (int i=0; i < s.children.size(); i++)
-    children.push (new Rhythmic_grouping (*s.children[i]));
-}
-
-void
-Rhythmic_grouping::operator=(Rhythmic_grouping const &s)
-{
-  junk();
-  copy (s);
-}
-
-Rhythmic_grouping::Rhythmic_grouping (Rhythmic_grouping const&s)
-{
-  init();
-  copy (s);
-}
-
-void
-Rhythmic_grouping::junk()
-{
-  delete interval_;
-  for (int i=0; i < children.size(); i++)
-    delete children[i];
-  init();
-}
-
-void
-Rhythmic_grouping::print() const    
-{
-#ifndef NPRINT
-  DOUT << "{ \n";
-  if (interval_)
-    DOUT <<" Interval "<< interval_->str();
-  for (int i=0; i < children.size(); i++) 
-    {
-      children[i]->print();
-    }
-  DOUT << "}\n";
-#endif
-}
-
-bool
-Rhythmic_grouping::child_fit_b (Moment start)
-{
-  if (children.size())
-    return (children.top()->interval ().right== start);
-
-  return true;
-}  
-
-void
-Rhythmic_grouping::add_child (Moment start, Moment len)
-{
-  Moment stop = start+len;
-  assert (child_fit_b (start));
-  children.push (new Rhythmic_grouping (MInterval (start, stop)));
-}
-
-Rhythmic_grouping::Rhythmic_grouping()
-{
-  interval_ =0;
-}
-
-int
-min_elt (Array<int> v)
-{
-  int i = 1000;                // ugh
-  for (int j = 0 ; j <  v.size(); j++)
-    i = i <? v[j];
-  return i;
-}
-
-Array<int>
-Rhythmic_grouping::generate_beams (Array<int> flags, int &flagidx)
-{
-  assert (!interval_) ;
-  
-  Array< Array<int> > children_beams;
-  for (int i=0; i < children.size(); i++) 
-    {
-      Array<int> child_beams;
-      if (children[i]->interval_) 
-       {
-         int f = flags[flagidx++];
-         child_beams.push (f);
-       }
-      else 
-       {
-         child_beams = children[i]->
-           generate_beams (flags, flagidx);
-       }
-      children_beams.push (child_beams);
-    }
-  Array<int> beams;
-  int lastm, m, nextm;
-  for (int i=0; i  < children_beams.size(); i++) 
-    {
-      bool add_left =  (i >0);
-      bool add_right = (i  < children_beams.size() -1);
-
-      if (!i)
-       m =  min_elt (children_beams[i]);
-      if (add_right)
-       nextm = min_elt (children_beams[i+1]);
-       
-      if (children_beams[i].size() == 1) 
-       {
-         if (add_right)
-           beams.push (m);
-         if (add_left)
-           beams.push (m);
-       }
-      else 
-       {
-         if (add_left) 
-           beams.push (lastm <? m);
-         beams.concat (children_beams[i]);
-         if (add_right)
-           beams.push (m <? nextm);
-       }
-      lastm = m;
-      m = nextm;       
-    }
-  assert (!(beams.size()%2));
-  return beams;
-}
-
-void
-Rhythmic_grouping::translate (Moment m)
-{
-  if (interval_)
-    *interval_ += m;
-  else
-    for (int i=0; i < children.size(); i++)
-      children[i]->translate (m);
-}
-
-void
-Rhythmic_grouping::extend (MInterval m) const
-{    
-  assert (m.left >= interval().left);
-  while (m.right  >interval().right) 
-    {
-      Array<Rhythmic_grouping*> a (children);
-      for (int i=0; i < a.size(); i++) 
-       {
-         a[i] =new Rhythmic_grouping (*children[i]);
-         a[i]->translate (children.top()->interval ().right);      
-       }
-      ((Rhythmic_grouping*)this)->children.concat (a);
-    }
-  assert (m.right <= interval().right);
-  OK();
-}
-
-Rhythmic_grouping
-parse_grouping (Array<int> beat_i_arr, Array<Moment> elt_length_arr)
-{
-  Moment here =0;
-  assert (beat_i_arr.size() == elt_length_arr.size ());
-  
-  Array<Rhythmic_grouping*> children;
-  for (int i=0; i < beat_i_arr.size(); i++) 
-    {
-      Moment last = here;
-      here += elt_length_arr[i] * Moment (beat_i_arr[i]);
-      children.push (
-                    new Rhythmic_grouping (MInterval (last, here),
-                                           beat_i_arr[i]));
-    }
-  return Rhythmic_grouping (children);
-}
-
index 7d539fb6660711336c865bb8fffccada7820191a..cf3c897efcbfec100c0a6153232ca47c6115b135 100644 (file)
@@ -69,7 +69,7 @@ public:
 
 class Partial_measure_req  : public Timing_req  {
 public:
-  Moment duration_;
+  Moment length_mom_;
 
   Partial_measure_req (Moment);
   REQUESTMETHODS(Partial_measure_req);
index 0e12f150fd97997ed58518b2f92760733c03b280..7028dbc92fafaf8bb2428eb8775ad3cf9a3f81b2 100644 (file)
@@ -34,7 +34,7 @@ public:
 
   
 protected:
-  virtual Moment now_moment () const;
+  virtual Moment now_mom () const;
   virtual Global_translator *global_l() { return this; }
 };
 
index ada7b4ab5c4ca221eca375a5b2867e8ca21b26a0..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,60 +0,0 @@
-/*
-  grouping.hh -- part of GNU LilyPond
-
-  (c) 1996--1998 Han-Wen Nienhuys
-*/
-
-#ifndef GROUPING_HH
-#define GROUPING_HH
-
-#include "minterval.hh"
-#include "array.hh"
-
-/** data structure which represents rhythmic units   this is a tree. It groupes notes according to rules
-
-  TODO Documentation. Unhairing
- */
-struct Rhythmic_grouping {
-    Array<Rhythmic_grouping*> children;
-    MInterval *interval_;
-    
-
-    Array<MInterval> intervals();
-    MInterval interval() const;
-    Moment length() const;
-    void intersect (MInterval);
-    
-    void operator=(Rhythmic_grouping const&);
-    Rhythmic_grouping (Rhythmic_grouping const&);
-    Rhythmic_grouping (MInterval, int n=1);
-    Rhythmic_grouping();
-    Rhythmic_grouping (Array<Rhythmic_grouping*>);
-    ~Rhythmic_grouping();
-
-    void add_child (Moment start, Moment len);
-    bool child_fit_b (Moment start);
-    void split (Rhythmic_grouping r);
-    void split (Array<MInterval>);
-    void split (int n);
-
-    void print() const;
-    void OK() const;
-
-    Array<int> generate_beams (Array<int>, int&);
-
-    /** multiply self to span #i#.
-      In implementation, this isn't really const, but conceptually it is.
-      */
-    void extend (MInterval i) const;
-    void translate (Moment);
-private:
-    void init();
-    void junk();
-    void copy (Rhythmic_grouping const&);
-};
-
-
-Rhythmic_grouping parse_grouping (Array<int> beat_i_arr, Array<Moment> elt_length_arr);
-
-
-#endif
index ef0029b418fbc84aa3db5f0eef454db3d296bfbf..85975ee8dd8a7b2d3379fd1dfe384566281822f8 100644 (file)
@@ -31,7 +31,7 @@ public:
   Midi_def();
   ~Midi_def();
 
-  Real duration_to_seconds_f (Moment);
+  Real length_mom_to_seconds_f (Moment);
   int get_tempo_i (Moment moment);
   void print() const;
   void set_tempo (Moment moment, int count_per_minute_i);
index 5b3eaf6a1a5484e4e8e858124ca7236ed5a91079..2b251c4286c485459b0ac09e79062f37392c6ea1 100644 (file)
@@ -112,7 +112,7 @@ struct Midi_note : public Midi_item {
   
   Midi_note (Audio_item* audio_item_l); 
 
-  Moment duration () const;
+  Moment length_mom () const;
   int pitch_i () const;
   virtual String str () const;
 
index 7cbbffee49f780c979d5f96f9e6bb2fe2f362bf4..9665ff9df45949fb13beacde87899dd88d322af6 100644 (file)
@@ -55,7 +55,7 @@ public:
   
   Simultaneous_music(Music_list *);
   virtual Musical_pitch to_relative_octave (Musical_pitch);
-  virtual Moment duration () const;
+  virtual Moment length_mom () const;
 };
 
 
@@ -84,6 +84,6 @@ public:
 
   virtual Musical_pitch to_relative_octave (Musical_pitch);
   Sequential_music(Music_list*);
-  virtual Moment duration () const;
+  virtual Moment length_mom () const;
 };
 #endif // Music_sequence_HH
index 26fea0ec7bec649bdb8e482bb6dc31f072194df0..adbd86979046bc98f4a1081d8b8cd50bda164640 100644 (file)
@@ -30,7 +30,7 @@ public:
   
   VIRTUAL_COPY_CONS(Music);
   Music_wrapper (Music_wrapper const&);
-  virtual Moment duration () const;
+  virtual Moment length_mom () const;
   virtual ~Music_wrapper ();
   virtual Musical_pitch to_relative_octave (Musical_pitch);
   
index 8f30e4469821cf537ab226714d3dfef3ad6ae47c..15ee2f7074fcbcc22231eaf99ed74b88039fb0a2 100644 (file)
@@ -44,7 +44,7 @@ public:
   virtual Musical_pitch to_relative_octave (Musical_pitch);
 
   /// The duration of this piece of music
-  virtual Moment duration () const;
+  virtual Moment length_mom () const;
 
   virtual ~Music(){}
   void print() const;
index 3fcf3b9cd60c2e8342b63b36aba2727bf4f5882b..eea7e90b167678c71a2c520623e1e4c6f4cf2cd6 100644 (file)
@@ -37,7 +37,7 @@ public:
     
   bool do_equal_b (Request*) const;
   void compress (Moment);
-  virtual Moment duration() const;
+  virtual Moment length_mom () const;
   static int compare (Rhythmic_req const&,Rhythmic_req const&);
   REQUESTMETHODS(Rhythmic_req);
 };
index df73bea785c5c5668039ac6e2288de572a5c5b8d..4364350592653d8f0ade328d4617bf1f343d3403 100644 (file)
@@ -86,7 +86,7 @@ public:
   /** convert a duration to an idealspacing
     influence using the geometric_ and  paratime_signatures.
     */
-  Real duration_to_dist (Moment, Real) const;
+  Real length_mom_to_dist (Moment, Real) const;
   Real geometric_spacing (Moment) const;
   Real arithmetic_constant (Moment minimal_mom) const;
   Real arithmetic_spacing (Moment mom,Real constant) const;
index 6175d45864782b4d7026d1283fa791fd313614aa..5e2e2b28c71abaac3f4e3e3eba3f62a05a7d2627 100644 (file)
@@ -29,7 +29,7 @@ public:
   
   virtual void do_print () const;
   virtual void transpose (Musical_pitch p);
-  virtual Moment duration () const;
+  virtual Moment length_mom () const;
   virtual Musical_pitch to_relative_octave (Musical_pitch p);
   VIRTUAL_COPY_CONS(Music);
 };
index d374d5929f4af2fd31dd6979e484463252b3d3d9..4d078dca4600246b53494772ab43e0cc95db8fd0 100644 (file)
@@ -18,9 +18,9 @@
 class Request_chord_iterator : public Music_iterator {
   Request_chord * elt_l () const;
   /**
-     cache elt_l ()->duration ().
+     cache elt_l ()->length_mom ().
    */
-  Moment elt_duration_;
+  Moment elt_length_mom_;
   bool last_b_;
 
 public:
diff --git a/lily/include/rhythmic-grouping.hh b/lily/include/rhythmic-grouping.hh
new file mode 100644 (file)
index 0000000..07bca7b
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+  rhythmic-grouping.hh -- part of GNU LilyPond
+
+  (c) 1996--1998 Han-Wen Nienhuys
+*/
+
+#ifndef RHYTHMIC_GROUPING_HH
+#define RHYTHMIC_GROUPING_HH
+
+#include "minterval.hh"
+#include "array.hh"
+
+/** data structure which represents rhythmic units   this is a tree. It groupes notes according to rules
+
+  TODO Documentation. Unhairing
+ */
+struct Rhythmic_grouping {
+    Array<Rhythmic_grouping*> children;
+    MInterval *interval_;
+    
+
+    Array<MInterval> intervals();
+    MInterval interval() const;
+    Moment length_mom () const;
+    void intersect (MInterval);
+    
+    void operator=(Rhythmic_grouping const&);
+    Rhythmic_grouping (Rhythmic_grouping const&);
+    Rhythmic_grouping (MInterval, int n=1);
+    Rhythmic_grouping();
+    Rhythmic_grouping (Array<Rhythmic_grouping*>);
+    ~Rhythmic_grouping();
+
+    void add_child (Moment start, Moment len);
+    bool child_fit_b (Moment start);
+    void split (Rhythmic_grouping r);
+    void split (Array<MInterval>);
+    void split (int n);
+
+    void print() const;
+    void OK() const;
+
+    Array<int> generate_beams (Array<int>, int&);
+
+    /** multiply self to span #i#.
+      In implementation, this isn't really const, but conceptually it is.
+      */
+    void extend (MInterval i) const;
+    void translate (Moment);
+private:
+    void init();
+    void junk();
+    void copy (Rhythmic_grouping const&);
+};
+
+
+Rhythmic_grouping parse_grouping (Array<int> beat_i_arr, Array<Moment> elt_length_arr);
+
+
+#endif // RHYTHMIC_GROUPING_HH
index 460939d59b8cf128ef0bfebfd9852a5bb38caf44..2fc7a6497fdbc1cf80be6e7b975054e343dd8ab0 100644 (file)
@@ -11,7 +11,7 @@
 #define METERGRAV_HH
 #include "engraver.hh"
 #include "time-description.hh"
-#include "grouping.hh"
+#include "rhythmic-grouping.hh"
 
 /**
   generate time_signatures. 
index 7074d9c873b6d256658d2b9e4a337c20a12cf57e..2e97184c5f685b4d38fd4b6c2cce2f1ec8717cac 100644 (file)
@@ -12,7 +12,7 @@
 
 #include "translator.hh"
 #include "time-description.hh"
-#include "grouping.hh"
+#include "rhythmic-grouping.hh"
 #include "parray.hh"
 
 class Timing_translator : public virtual Translator
index f089df51b417f464f570999971bb6e25d7dcca74..997735483ad6a0826cccc3b3ecaf5c96cf9309c4 100644 (file)
@@ -61,7 +61,7 @@ public:
     */
   Music_output_def *output_def_l () const;
   Scalar get_property (String, Translator_group **) const;
-  virtual Moment now_moment () const;  
+  virtual Moment now_mom () const;  
 
 protected:
    enum { 
index e12162159305f57b3dff512cbd25f6626af34fea..81ea51e5afe96857ec4db889caf40da0fc2968f6 100644 (file)
@@ -31,7 +31,7 @@ Midi_def::~Midi_def()
 }
 
 Real
-Midi_def::duration_to_seconds_f (Moment mom)
+Midi_def::length_mom_to_seconds_f (Moment mom)
 {
   if (!mom)
     return 0;
index 106ee8bcbaaa1f249fe7e4c89b69a51e1f0fe5ed..2dd86eddc1493891e6bd1b69badc7cd8faa6180e 100644 (file)
@@ -403,9 +403,9 @@ Midi_note::Midi_note (Audio_item* audio_item_l)
 }
 
 Moment
-Midi_note::duration () const
+Midi_note::length_mom () const
 {
-  Moment m = dynamic_cast <Rhythmic_req *> (audio_item_l_->req_l_)->duration ();
+  Moment m = dynamic_cast <Rhythmic_req *> (audio_item_l_->req_l_)->length_mom ();
   if (m < Moment (1, 1000))
     {
       warning (_ ("silly duration"));
index 1af44cd1fb65ee70d441b6c628aa1b97f1cd8ef2..3709fc755c9eacfe3c35b61bcc7611d798d40de5 100644 (file)
@@ -45,7 +45,7 @@ Midi_walker::~Midi_walker()
 void 
 Midi_walker::do_start_note (Midi_note* note_p)
 {
-  Moment stop_mom = note_p->duration() + ptr ()->audio_column_l_->at_mom ();
+  Moment stop_mom = note_p->length_mom () + ptr ()->audio_column_l_->at_mom ();
   for (int i=0; i < stop_note_queue.size(); i++) 
     {
       if (stop_note_queue[i].val->pitch_i() == note_p->pitch_i ()) 
index 8dd071d6d5acbe89dd185b897644eafbb2cf3673..0143543c6e94b9d8844b9fcafece92c431247879 100644 (file)
@@ -49,13 +49,13 @@ Multi_measure_rest_engraver::do_try_music (Music* req_l)
    {
      if (multi_measure_req_l_)
        if (!multi_measure_req_l_->equal_b (mr)
-          || rest_moments_[START] != now_moment ())
+          || rest_moments_[START] != now_mom ())
         return false;
   
      multi_measure_req_l_ = mr;
-     rest_moments_[START] = now_moment ();
+     rest_moments_[START] = now_mom ();
      
-     rest_moments_[STOP] = rest_moments_[START] + multi_measure_req_l_->duration_.length ();
+     rest_moments_[STOP] = rest_moments_[START] + multi_measure_req_l_->duration_.length_mom ();
      return true;
    }
  return false;
@@ -76,7 +76,7 @@ Multi_measure_rest_engraver::do_process_requests ()
 void
 Multi_measure_rest_engraver::do_pre_move_processing ()
 {
-  Moment now (now_moment ());
+  Moment now (now_mom ());
   Time_description const *time = get_staff_info().time_C_;
   if (mmrest_p_ && (now >= rest_moments_[START]) 
     && !time->whole_in_measure_
@@ -98,7 +98,7 @@ void
 Multi_measure_rest_engraver::do_post_move_processing ()
 {
   Time_description const *time = get_staff_info().time_C_;
-  Moment now (now_moment ());
+  Moment now (now_mom ());
 
   if (mmrest_p_ && !time->whole_in_measure_)
     {
index 3d155a90c67fc132ac966aacff0e8a62d9efff81..bf409cb878bea3e01b28d8c8c741148899c86a8b 100644 (file)
 #include "main.hh"
 
 Moment
-Simultaneous_music::duration () const
+Simultaneous_music::length_mom () const
 {
   Moment dur = 0;
   for (iter (music_p_list_p_->top(), i); i.ok (); i++)
-    dur = dur >? i->duration ();
+    dur = dur >? i->length_mom ();
 
   return dur;
 }
@@ -41,12 +41,12 @@ Sequential_music::Sequential_music(Music_list *p)
 }
 
 Moment
-Sequential_music::duration () const
+Sequential_music::length_mom () const
 {
   Moment last=0;
   for (iter (music_p_list_p_->top(), i); i.ok (); i++) 
     {
-      last += i->duration ();
+      last += i->length_mom ();
     }
   return  last;
 }
index 57ab04b7414f43bcf73f4cc363e8cd58342d34ce..b84394d86d82ebe86a50e88ed7d53df4a2e25c02 100644 (file)
@@ -45,9 +45,9 @@ Music_wrapper::Music_wrapper(Music*p)
 
 
 Moment
-Music_wrapper::duration () const
+Music_wrapper::length_mom () const
 {
-  return element_p_->duration ();
+  return element_p_->length_mom ();
 }
 
 
index 8d7ce5cb881c3d4acbbc54613875fb0c86529329..ffecc3fafd5bc812a5748d3bdc760c7d2c95462a 100644 (file)
@@ -27,7 +27,7 @@ Music::do_print() const
 }
 
 Moment
-Music::duration () const
+Music::length_mom () const
 {
   return 0;
 }
index b573a4f26476e3a73d300574f8c65ee4b752ddcc..574e08dcad70d27d8fbf72f9488bf71e89c99b22 100644 (file)
@@ -136,7 +136,7 @@ Tonic_req::do_print () const
 int
 Rhythmic_req::compare (Rhythmic_req const &r1, Rhythmic_req const &r2)
 {
-  return (r1.duration () - r2.duration ());
+  return (r1.length_mom () - r2.length_mom ());
 }
 
 bool
@@ -160,9 +160,9 @@ Rhythmic_req::do_print () const
 
 
 Moment
-Rhythmic_req::duration () const
+Rhythmic_req::length_mom () const
 {
-  return duration_.length ();
+  return duration_.length_mom ();
 }
 
 void
@@ -322,7 +322,7 @@ void
 Skip_req::do_print () const
 {
 #ifndef NPRINT
-  DOUT << "duration: " << duration ();
+  DOUT << "duration: " << length_mom ();
 #endif
 }
 
index 626881eea545ea2ceeb02e324039d32ffaca00bc..8f6cefcc497d13a2c7da6f35674f77fcbd8c0cf3 100644 (file)
@@ -109,7 +109,7 @@ SCMVAR(linewidth);
 }
 
 Real
-Paper_def::duration_to_dist (Moment d,Real k) const
+Paper_def::length_mom_to_dist (Moment d,Real k) const
 {
   return arithmetic_spacing (d,k);
 }
index 73a7557a4758d7be0d0324e8012df4c010377889..d7891b9b378d9ccbfd96d303a5af8b0ffad58f36 100644 (file)
@@ -690,7 +690,7 @@ midi_body: /* empty */              {
                $$-> assign_translator ($2);
        }
        | midi_body tempo_request ';' {
-               $$->set_tempo ($2->dur_.length (), $2->metronome_i_);
+               $$->set_tempo ($2->dur_.length_mom (), $2->metronome_i_);
                delete $2;
        }
        | midi_body error {
@@ -946,7 +946,7 @@ verbose_command_req:
                $$ = new Cadenza_req ($2);
        }
        | PARTIAL duration_length       {
-               $$ = new Partial_measure_req ($2->length ());
+               $$ = new Partial_measure_req ($2->length_mom ());
                delete $2;
        }
        | CLEF STRING {
index ab634c71da15e37d9e1f17629d6ccda180305a19..2fb69d16af2805140672e4feff9b3b813b17afc7 100644 (file)
@@ -36,14 +36,14 @@ Repeat_engraver::do_try_music (Music* m)
         return true;
  
       Music_sequence* alt = r->alternative_p_;
-      Moment stop_mom = now_moment () + r->repeat_p_->duration ();
+      Moment stop_mom = now_mom () + r->repeat_p_->length_mom ();
       for (PCursor<Music*> i (alt->music_p_list_p_->top ()); i.ok () && (i != alt->music_p_list_p_->bottom ()); i++)
        {
-         stop_mom += i->duration ();
+         stop_mom += i->length_mom ();
          if (dynamic_cast<Simultaneous_music *> (alt))
            break;
        }
-      Moment alt_mom = now_moment () + r->repeat_p_->duration ();
+      Moment alt_mom = now_mom () + r->repeat_p_->length_mom ();
       /*
         TODO: 
          figure out what we don't want.
@@ -63,9 +63,9 @@ Repeat_engraver::do_try_music (Music* m)
         {
          alternative_music_arr_.push (i.ptr ());
          alternative_start_mom_arr_.push (alt_mom);
-         alternative_stop_mom_arr_.push (alt_mom + i->duration ());
+         alternative_stop_mom_arr_.push (alt_mom + i->length_mom ());
          if (!dynamic_cast<Simultaneous_music *> (alt))
-           alt_mom += i->duration ();
+           alt_mom += i->length_mom ();
        }
       return true;
     }
@@ -75,7 +75,7 @@ Repeat_engraver::do_try_music (Music* m)
 void
 Repeat_engraver::acknowledge_element (Score_element_info i)
 {
-  Moment now = now_moment ();
+  Moment now = now_mom ();
   if (Note_column *c = dynamic_cast<Note_column *> (i.elem_l_))
     {
       for (int i = 0; i < volta_p_arr_.size (); i++)
@@ -101,7 +101,7 @@ Repeat_engraver::do_removal_processing ()
 void
 Repeat_engraver::do_process_requests ()
 {  
-  Moment now = now_moment ();
+  Moment now = now_mom ();
   Bar_engraver* bar_engraver_l = dynamic_cast <Bar_engraver*>
     (daddy_grav_l ()->get_simple_translator ("Bar_engraver"));
   for (int i = bar_b_arr_.size (); i < repeated_music_arr_.size (); i++)
@@ -137,7 +137,7 @@ Repeat_engraver::do_process_requests ()
 void 
 Repeat_engraver::do_pre_move_processing ()
 {
-  Moment now = now_moment ();
+  Moment now = now_mom ();
   for (int i = bar_b_arr_.size (); i--; )
     {
       if (bar_b_arr_[i])
@@ -170,7 +170,7 @@ Repeat_engraver::do_post_move_processing ()
 {
 #if 0
   Time_description const *time = get_staff_info().time_C_;
-  Moment now = now_moment ();
+  Moment now = now_mom ();
   for (int i = volta_p_arr_.size (); i--; )
     {
       if ((now > alternative_stop_mom_arr_[i])
index 8c6982ce7beb85b6febaa9fb96c5590d37b94ef7..31d77da08ee6fb22261451b1df889f63ec3631a3 100644 (file)
@@ -72,10 +72,10 @@ Repeated_music_iterator::next_moment () const
   else if (alternative_iter_p_)
     return alternative_iter_p_->next_moment () + here_mom_;
   // huh?
-//  return repeated_music_l ()->repeat_p_->duration () 
+//  return repeated_music_l ()->repeat_p_->length_mom () 
 //    * Moment (repeated_music_l ()->repeats_i_)
-//   + repeated_music_l ()->alternative_p_->duration () + here_mom_;
-  return repeated_music_l ()->alternative_p_->duration () + here_mom_;
+//   + repeated_music_l ()->alternative_p_->length_mom () + here_mom_;
+  return repeated_music_l ()->alternative_p_->length_mom () + here_mom_;
 }
 
 bool
@@ -112,7 +112,7 @@ Repeated_music_iterator::start_next_element ()
       repeat_iter_p_ = 0;
       alternative_iter_p_ = dynamic_cast<Music_list_iterator*>
        (get_iterator_p ((Music*)repeated_music_l ()->alternative_p_));  
-      here_mom_ += repeated_music_l ()->repeat_p_->duration ();
+      here_mom_ += repeated_music_l ()->repeat_p_->length_mom ();
     }
   else if (alternative_iter_p_)
     {
@@ -128,7 +128,7 @@ Repeated_music_iterator::start_next_element ()
          unfold_i_--;
          repeat_iter_p_ = get_iterator_p (repeated_music_l ()->repeat_p_);
          // urg, assume same length alternatives for now...
-//       here_mom_ += repeated_music_l ()->alternative_p_->music_p_list_p_->top ()->duration ();
+//       here_mom_ += repeated_music_l ()->alternative_p_->music_p_list_p_->top ()->length_mom ();
          /*
            URG
            this is *wrong* but at least it doesn't dump core
@@ -137,7 +137,7 @@ Repeated_music_iterator::start_next_element ()
 
            how to intercept this...
           */
-         here_mom_ += repeated_music_l ()->alternative_p_->duration ();
+         here_mom_ += repeated_music_l ()->alternative_p_->length_mom ();
        }
     }
 }
index 1bbd2be8c25d2f046456e63aa882998a39b3a8b1..e34a5c8da64606079c1aaa11d0cc74bb02f670e4 100644 (file)
@@ -51,13 +51,13 @@ Repeated_music::transpose (Musical_pitch p)
 }
 
 Moment
-Repeated_music::duration () const
+Repeated_music::length_mom () const
 {
   Moment m;
   if (repeat_p_)
-    m += repeat_p_->duration ();
+    m += repeat_p_->length_mom ();
   if (alternative_p_)
-    m += alternative_p_->duration ();
+    m += alternative_p_->length_mom ();
   return m;
 }
 
index 410a38d37cd7cbfb870c60f5395e6154484b7e06..b2f8a712a4b6182d8ecae57fe04d0568f2c8b38d 100644 (file)
@@ -17,7 +17,7 @@
 void
 Request_chord_iterator::construct_children()
 {
-  elt_duration_ =elt_l ()->duration ();
+  elt_length_mom_ =elt_l ()->length_mom ();
   get_req_translator_l();
 }
 
@@ -36,7 +36,7 @@ Request_chord_iterator::Request_chord_iterator ()
 bool
 Request_chord_iterator::ok() const
 {
-  return (elt_duration_ && !last_b_) || first_b_;
+  return (elt_length_mom_ && !last_b_) || first_b_;
 }
 
 
@@ -46,7 +46,7 @@ Request_chord_iterator::next_moment() const
 {
   Moment m (0);
   if  (!first_b_)
-    m = elt_duration_;
+    m = elt_length_mom_;
   return m;
 }
 
@@ -54,7 +54,7 @@ void
 Request_chord_iterator::do_print() const
 {
 #ifndef NPRINT
-  DOUT << "duration: " << elt_duration_;
+  DOUT << "duration: " << elt_length_mom_;
 #endif
 }
 
@@ -78,6 +78,6 @@ Request_chord_iterator::do_process_and_next (Moment mom)
       first_b_ = false;
     }
 
-  if (mom >= elt_duration_)
+  if (mom >= elt_length_mom_)
     last_b_ = true;
 }
diff --git a/lily/rhythmic-grouping.cc b/lily/rhythmic-grouping.cc
new file mode 100644 (file)
index 0000000..ad2f2b4
--- /dev/null
@@ -0,0 +1,383 @@
+/*
+  rhythmic-grouping.cc -- implement Rhythmic_grouping
+
+  source file of the GNU LilyPond music typesetter
+
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#include "debug.hh"
+#include "rhythmic-grouping.hh"
+#include "interval.hh"
+
+void
+Rhythmic_grouping::init()
+{
+  interval_ = 0;
+  children.clear();     
+}
+
+void
+Rhythmic_grouping::OK() const
+{
+#ifndef NDEBUG
+  assert (bool (children.size()) != bool (interval_));
+
+  for (int i= 0; i < children.size(); i++) 
+    {
+      children[i]->OK();
+      if (i>0)
+       assert (children[i-1]->interval().right ==
+               children[i]->interval().left);
+    }
+#endif
+}
+
+Moment
+Rhythmic_grouping::length_mom () const
+{
+  return interval().length ();
+}
+
+MInterval
+Rhythmic_grouping::interval() const
+{
+  if (interval_)
+    return *interval_;
+  else
+    return
+      MInterval (children[0]->interval().left,
+                children.top()->interval ().right);
+}
+
+void
+Rhythmic_grouping::split (Rhythmic_grouping r)
+{
+  if (interval_)
+    return ;
+  
+  r.intersect (interval());
+  split (r.intervals());
+  
+  for (int i= 0; i < children.size(); i++) 
+    {
+      if (!children[i]->interval_) 
+       {
+         Rhythmic_grouping here (r);   
+         children[i]->split (here);
+       }
+    }
+}
+
+
+Array<MInterval>
+Rhythmic_grouping::intervals()
+{
+  Array<MInterval> r;
+  if (interval_ || children.size() == 1) 
+    {
+      MInterval i (interval());
+      MInterval r1(i), r2(i);
+      r1.right = r2.left = i.center();
+      r.push (r1); r.push (r2);
+    }
+  else 
+    {
+      for (int i=0; i < children.size(); i++)
+       r.push (children[i]->interval());
+    }
+  return r;
+}
+
+void
+Rhythmic_grouping::intersect (MInterval t)
+{
+  if (interval_) 
+    {
+      interval_->intersect (t);
+      return;
+    }
+  
+  for (int i=0; i < children.size(); i++) 
+    {
+      MInterval inter = intersection (t, children[i]->interval());
+      if (inter.empty_b() || inter.length () <= Moment (0)) 
+       {
+         delete children[i];
+         children[i] =0;
+       }
+      else 
+       {
+         children[i]->intersect (t);
+       }
+    }
+  for (int i=0; i < children.size();) 
+    {
+      if (!children[i])
+       children.del (i);
+      else
+       i++;
+    }
+
+}
+
+/**
+  Put our children in branches of #this#.
+  The min and max time intervals coincide with elements of #splitpoints#
+
+  I really should be documenting what is happening here, but I find
+  that difficult, since I don't really understand what's going on here.
+
+  */
+void
+Rhythmic_grouping::split (Array<MInterval> splitpoints)
+{
+  //check on splitpoints..
+  int j = 0, i = 0, starti = 0, startj = 0;
+  
+  Array<Rhythmic_grouping*> ch;
+  while (1) 
+    {
+      if  (i >= children.size() || j >= splitpoints.size ())
+       break;
+       
+      assert (
+             children[starti]->interval().left== splitpoints[startj].left);
+      if (children[i]->interval().right < splitpoints[j].right) 
+       {
+         i ++;
+       }
+      else if (children[i]->interval().right > splitpoints[j].right) 
+       {
+         j ++;
+       }
+      else 
+       {
+
+         if (i == starti) 
+           {
+             ch.push (children[i]);
+           }
+         else 
+           {
+             Rhythmic_grouping *newchild=new Rhythmic_grouping (
+                                                                children.slice (starti, i+1));
+
+             ch.push (newchild);
+           }
+         i ++;
+         j++;
+         starti = i;
+         startj = j;
+
+
+       }
+    }
+  if (ch.size() != 1)
+    children = ch;
+}
+
+
+Rhythmic_grouping::Rhythmic_grouping (MInterval t, int n)
+{
+  init();
+  if (n == 1 || !n) 
+    {
+      interval_ = new MInterval (t);
+      return;
+    }
+  Moment dt = t.length ()/Moment (n);
+  MInterval basic = MInterval (t.left, t.left+dt);
+  for (int i= 0; i < n; i++)
+    children.push (new Rhythmic_grouping (dt*Moment (i) + basic));
+}
+
+
+Rhythmic_grouping::Rhythmic_grouping (Array<Rhythmic_grouping*> r)
+  :children (r)
+{
+  interval_ =0;
+}
+
+Rhythmic_grouping::~Rhythmic_grouping()
+{
+  junk();    
+}
+
+void
+Rhythmic_grouping::copy (Rhythmic_grouping const&s)
+{
+  interval_ =  (s.interval_)? new MInterval (*s.interval_) : 0;
+  for (int i=0; i < s.children.size(); i++)
+    children.push (new Rhythmic_grouping (*s.children[i]));
+}
+
+void
+Rhythmic_grouping::operator=(Rhythmic_grouping const &s)
+{
+  junk();
+  copy (s);
+}
+
+Rhythmic_grouping::Rhythmic_grouping (Rhythmic_grouping const&s)
+{
+  init();
+  copy (s);
+}
+
+void
+Rhythmic_grouping::junk()
+{
+  delete interval_;
+  for (int i=0; i < children.size(); i++)
+    delete children[i];
+  init();
+}
+
+void
+Rhythmic_grouping::print() const    
+{
+#ifndef NPRINT
+  DOUT << "{ \n";
+  if (interval_)
+    DOUT <<" Interval "<< interval_->str();
+  for (int i=0; i < children.size(); i++) 
+    {
+      children[i]->print();
+    }
+  DOUT << "}\n";
+#endif
+}
+
+bool
+Rhythmic_grouping::child_fit_b (Moment start)
+{
+  if (children.size())
+    return (children.top()->interval ().right== start);
+
+  return true;
+}  
+
+void
+Rhythmic_grouping::add_child (Moment start, Moment len)
+{
+  Moment stop = start+len;
+  assert (child_fit_b (start));
+  children.push (new Rhythmic_grouping (MInterval (start, stop)));
+}
+
+Rhythmic_grouping::Rhythmic_grouping()
+{
+  interval_ =0;
+}
+
+int
+min_elt (Array<int> v)
+{
+  int i = 1000;                // ugh
+  for (int j = 0 ; j <  v.size(); j++)
+    i = i <? v[j];
+  return i;
+}
+
+Array<int>
+Rhythmic_grouping::generate_beams (Array<int> flags, int &flagidx)
+{
+  assert (!interval_) ;
+  
+  Array< Array<int> > children_beams;
+  for (int i=0; i < children.size(); i++) 
+    {
+      Array<int> child_beams;
+      if (children[i]->interval_) 
+       {
+         int f = flags[flagidx++];
+         child_beams.push (f);
+       }
+      else 
+       {
+         child_beams = children[i]->
+           generate_beams (flags, flagidx);
+       }
+      children_beams.push (child_beams);
+    }
+  Array<int> beams;
+  int lastm, m, nextm;
+  for (int i=0; i  < children_beams.size(); i++) 
+    {
+      bool add_left =  (i >0);
+      bool add_right = (i  < children_beams.size() -1);
+
+      if (!i)
+       m =  min_elt (children_beams[i]);
+      if (add_right)
+       nextm = min_elt (children_beams[i+1]);
+       
+      if (children_beams[i].size() == 1) 
+       {
+         if (add_right)
+           beams.push (m);
+         if (add_left)
+           beams.push (m);
+       }
+      else 
+       {
+         if (add_left) 
+           beams.push (lastm <? m);
+         beams.concat (children_beams[i]);
+         if (add_right)
+           beams.push (m <? nextm);
+       }
+      lastm = m;
+      m = nextm;       
+    }
+  assert (!(beams.size()%2));
+  return beams;
+}
+
+void
+Rhythmic_grouping::translate (Moment m)
+{
+  if (interval_)
+    *interval_ += m;
+  else
+    for (int i=0; i < children.size(); i++)
+      children[i]->translate (m);
+}
+
+void
+Rhythmic_grouping::extend (MInterval m) const
+{    
+  assert (m.left >= interval().left);
+  while (m.right  >interval().right) 
+    {
+      Array<Rhythmic_grouping*> a (children);
+      for (int i=0; i < a.size(); i++) 
+       {
+         a[i] =new Rhythmic_grouping (*children[i]);
+         a[i]->translate (children.top()->interval ().right);      
+       }
+      ((Rhythmic_grouping*)this)->children.concat (a);
+    }
+  assert (m.right <= interval().right);
+  OK();
+}
+
+Rhythmic_grouping
+parse_grouping (Array<int> beat_i_arr, Array<Moment> elt_length_arr)
+{
+  Moment here =0;
+  assert (beat_i_arr.size() == elt_length_arr.size ());
+  
+  Array<Rhythmic_grouping*> children;
+  for (int i=0; i < beat_i_arr.size(); i++) 
+    {
+      Moment last = here;
+      here += elt_length_arr[i] * Moment (beat_i_arr[i]);
+      children.push (
+                    new Rhythmic_grouping (MInterval (last, here),
+                                           beat_i_arr[i]));
+    }
+  return Rhythmic_grouping (children);
+}
+
index e1ab3ab2fb5ea2e055d531f17ac289792b8c35df..c94779bc3a7cbb67424afa6a109780f9807fa992 100644 (file)
@@ -106,7 +106,7 @@ Score_engraver::do_announces()
          {
            if (Rhythmic_req *rq = dynamic_cast <Rhythmic_req *> (announce_info_arr_[i].req_l_))
              {
-               musical_column_l_->add_duration (rq->duration());
+               musical_column_l_->add_duration (rq->length_mom ());
              }
          }
       Engraver_group_engraver::do_announces();
index 291616b8822d81c84fa1228a7f713aa5b5f87859..4f85afc8ff71bc05f018e59d07d52f98b9d0a1e1 100644 (file)
@@ -58,7 +58,7 @@ Score::run_translator (Music_output_def *odef_l)
       return ;
     }
   *mlog << '\n' << _("Interpreting music...") << flush;
-  trans_p->last_mom_ = music_p_->duration ();
+  trans_p->last_mom_ = music_p_->length_mom ();
 
   Music_iterator * iter = Music_iterator::static_get_iterator_p (music_p_, trans_p);
   
index 5ec0a76cd98588483c468654e1b5d02177d3c31a..d5ba03eef698f46ea8764c48daa172b651924220 100644 (file)
@@ -50,7 +50,7 @@ Sequential_music_iterator::leave_element()
 {
   delete iter_p_;
   iter_p_ =0;
-  Moment elt_time = cursor_p_->ptr()->duration ();
+  Moment elt_time = cursor_p_->ptr()->length_mom ();
   here_mom_ += elt_time;
   cursor_p_->next();
 }
index cbf3f2e7c305c2a3add6243e33faf9d85fb5f48b..3ca32eba6c73f0d1cf3cb7ea2463229d2ce482a1 100644 (file)
@@ -599,7 +599,7 @@ Spring_spacer::calc_idealspacing()
          if (delta_t)
            {
              Real k=  paper_l()->arithmetic_constant (context_shortest_arr[i]);
-             durational_distance =  paper_l()->duration_to_dist (delta_t,k);
+             durational_distance =  paper_l()->length_mom_to_dist (delta_t,k);
            }
          symbol_distance += -cols_[i+1].width_[LEFT];
  
@@ -632,7 +632,7 @@ Spring_spacer::calc_idealspacing()
            }
          Moment delta_t = scol_l (i+1)->when() - scol_l (i)->when ();
          Real k=  paper_l()->arithmetic_constant(context_shortest);
-         Real dist = paper_l()->duration_to_dist (shortest_playing_len, k);
+         Real dist = paper_l()->length_mom_to_dist (shortest_playing_len, k);
          dist *= (double)(delta_t / shortest_playing_len);
 
          /*
index 3b1301cbb8a59b19cb900079816b6bf700299271..54fe0efa1f29b958d6f217116dd551dd56cc9812 100644 (file)
@@ -49,7 +49,7 @@ Staff_margin_engraver::acknowledge_element (Score_element_info i)
 
   String long_str = get_property ("instrument", 0);
   String str = get_property ("instr", 0);
-  if (now_moment () > Moment (0) && str.length_i ())
+  if (now_mom () > Moment (0) && str.length_i ())
     long_str = str;
 
   if (long_str.empty_b ())
index 9a78dd4109829124ee8bddde34f71b32f2fd4876..2a8cc741dd1c5075d381ac13c87628a015c67cc9 100644 (file)
@@ -36,7 +36,7 @@ Tie_engraver::acknowledge_element (Score_element_info i)
   if (Note_head *nh = dynamic_cast<Note_head *> (i.elem_l_))
     {
       Note_req * m = dynamic_cast<Note_req* > (i.req_l_);
-      now_heads_.push (CHead_melodic_tuple (nh, m, now_moment()+ m->duration ()));
+      now_heads_.push (CHead_melodic_tuple (nh, m, now_mom()+ m->length_mom ()));
     }
 }
 
@@ -45,7 +45,7 @@ Tie_engraver::do_process_requests ()
 {
   if (req_l_)
     {
-      Moment now = now_moment ();
+      Moment now = now_mom ();
       Link_array<Note_head> nharr;
       
       stopped_heads_.clear ();
@@ -116,7 +116,7 @@ void
 Tie_engraver::do_post_move_processing ()
 {
   req_l_ =0;
-  Moment now = now_moment ();
+  Moment now = now_mom ();
   while (past_notes_pq_.size () && past_notes_pq_.front ().end_ < now)
     past_notes_pq_.delmin ();
 }
index 22ab2d9acc761770355926bb80694538e948e555..cdbc54aebed99bd81ba155e44fa789199bb764a1 100644 (file)
@@ -18,7 +18,7 @@ Time_description::str () const
   s += "at ";
   s += when_.str ();
   s +="\ntime_signature " + (whole_per_measure_/one_beat_).str () +":" +
-        (Rational (Rational (1)/one_beat_)).str ();
+        (Moment (Moment (1)/one_beat_)).str ();
   s += "\nposition " + to_str (bars_i_) + ":"+ whole_in_measure_.str () +"\n}\n";
   return s;
 }
@@ -69,7 +69,7 @@ Time_description::Time_description()
 void
 Time_description::add (Moment dt)
 {
-  assert (dt >= Rational (0));
+  assert (dt >= Moment (0));
   when_ +=  dt;
   whole_in_measure_ += dt;
 
@@ -84,7 +84,7 @@ void
 Time_description::set_time_signature (int l, int o)
 {
   assert (o);
-  one_beat_ = Rational (1)/Moment (o);
+  one_beat_ = Moment (1)/Moment (o);
   whole_per_measure_ = Moment (l) * one_beat_;
 }
 
@@ -102,7 +102,7 @@ Time_description::allow_time_signature_change_b()
 String
 Time_description::try_set_partial_str (Moment p) const
 {
-  if (p<Rational (0))
+  if (p<Moment (0))
        return (_ ("partial measure must be non-negative"));
   if (p > whole_per_measure_)
        return (_ ("partial measure too large"));
index 8e8d58a76d1cce368b55da74997c734a0faffd18..26e2f21dec54a2df7b8b6881bc02c0a7557dd6b3 100644 (file)
@@ -74,7 +74,7 @@ Timing_translator::do_process_requests()
        }
       else if (Partial_measure_req *pm = dynamic_cast <Partial_measure_req *> (tr_l))
        {
-         Moment m = pm->duration_;
+         Moment m = pm->length_mom_;
          String error = time_.try_set_partial_str (m);
          if (error.length_i ())
            {
@@ -131,13 +131,13 @@ ADD_THIS_TRANSLATOR(Timing_translator);
 void
 Timing_translator::do_creation_processing()
 {
-  time_.when_ = now_moment ();
+  time_.when_ = now_mom ();
 }
 
 void
 Timing_translator::do_post_move_processing()
 {
-  time_.add (now_moment ()  - time_.when_);
+  time_.add (now_mom ()  - time_.when_);
 }
 
 void
index b378cad83a0a5ace7287742686f7dc1210298fdf..49cf960b399ea7697e4743976002facdc89fc5cb 100644 (file)
@@ -245,7 +245,7 @@ Translator_group::nongroup_l_arr () const
 void
 Translator_group::terminate_translator (Translator*r_l)
 {
-  DOUT << "Removing " << classname (r_l) << " at " << now_moment () << '\n';
+  DOUT << "Removing " << classname (r_l) << " at " << now_mom () << '\n';
   r_l->removal_processing();
   Translator * trans_p =remove_translator_p (r_l);
 
index 30205ed7fd6e62e8fabd375c1422f8d81e8d37ab..2e20760894acadee45d66b2d6966d50e5c882bc3 100644 (file)
@@ -47,9 +47,9 @@ Translator::do_try_music (Music *)
                            
 
 Moment
-Translator::now_moment () const
+Translator::now_mom () const
 {
-  return daddy_trans_l_->now_moment ();
+  return daddy_trans_l_->now_mom ();
 }
 
 
index 5bcfa0aa5660741356f81e24b26e2fec00d44018..b751d5eae7d4d4a9ae825e4642c3e786ba9f79d0 100644 (file)
@@ -25,7 +25,7 @@ Tuplet_engraver::do_try_music (Music *r)
       if (!dynamic_cast<Request_chord*> (el))
        {
          compressed_music_arr_.push (c);
-         stop_moments_.push (now_moment () + c->duration ());
+         stop_moments_.push (now_mom () + c->length_mom ());
        }
       return true;
     }
@@ -66,7 +66,7 @@ Tuplet_engraver::acknowledge_element (Score_element_info i)
 void
 Tuplet_engraver::do_post_move_processing ()
 {
-  Moment now = now_moment ();
+  Moment now = now_mom ();
   for (int i= started_span_p_arr_.size (); i--; )
     {
       if (now >= stop_moments_[i])