]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.3.85.jcn5
authorJan Nieuwenhuizen <janneke@gnu.org>
Wed, 13 Sep 2000 14:09:08 +0000 (16:09 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Wed, 13 Sep 2000 14:09:08 +0000 (16:09 +0200)
1.3.85.jcn5
===========

* Modified part-combiner to use new get_music ()/next () music iterator
  functionality.

13 files changed:
CHANGES
VERSION
lily/include/interpretation-context-handle.hh
lily/include/music-iterator.hh
lily/include/part-combine-music-iterator.hh
lily/include/simple-music-iterator.hh
lily/interpretation-context-handle.cc
lily/music-iterator.cc
lily/music-wrapper-iterator.cc
lily/part-combine-music-iterator.cc
lily/request-chord-iterator.cc
lily/sequential-music-iterator.cc
lily/translator-group.cc

diff --git a/CHANGES b/CHANGES
index d2632bd90b90dbb33602f3fc81a4c6d9e4fdf1fc..39df550cb1c07448ad73bad589272f9fd38536bd 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+1.3.85.jcn5
+===========
+
+* Modified part-combiner to use new get_music ()/next () music iterator
+  functionality.
+
 1.3.85.jcn4
 ===========
 
diff --git a/VERSION b/VERSION
index 606e08f2f9cff270ff6c9632353cc8fa6c48031f..988cb0b6140c2568e264653d60dfee24e5fe24ca 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=3
 PATCH_LEVEL=85
-MY_PATCH_LEVEL=jcn4
+MY_PATCH_LEVEL=jcn5
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
index fc15f7a19db3efc765d05490e7f1db62928a7c34..cb788f124a9c5e833d9e1806e67d2fc1dd0e4f30 100644 (file)
 
 class Interpretation_context_handle
 {
-  Translator_group * report_to_l_;
-public:
-  void down ();
-  void up (Translator_group*);
 public:
   ~Interpretation_context_handle ();
   Interpretation_context_handle ();
+  Interpretation_context_handle* clone () const;
   void set_translator (Translator_group*);
   bool try_music (Music *);
   void operator =(Interpretation_context_handle const&);
   Interpretation_context_handle (Interpretation_context_handle const&);
   Translator_group * report_to_l () const;
+
+private:
+  Translator_group * report_to_l_;
+  void down ();
+  void up (Translator_group*);
 };
 
 #endif /* INTERPRETATION_CONTEXT_HANDLE_HH */
index 81b1bfe0bc4879aca4a47645e121a05185d54d2c..87644b494f8fdb225c0b4f8f698982c068984d05 100644 (file)
  */
 class Music_iterator
 {
-  //private:
-public:
-  Interpretation_context_handle handle_;
-
-protected:
-  Music  * music_l_;
-
-  /// ugh. JUNKME
-  bool first_b_;
-
-  /**
-    Do the actual printing.  This should be overriden in derived classes.  It 
-    is called by #print#, in the public interface
-   */
-  virtual void do_print() const;
-    
-  /**
-    Find a bottom notation context to deliver requests to.
-   */
-  virtual Translator_group* get_req_translator_l();
-
-  /**
-    Get an iterator for MUS, inheriting the translation unit from THIS.
-   */
-  Music_iterator* get_iterator_p (Music *mus) const;
-
-  /** Do the actual move.  This should be overriden in derived
-    classes.  It is called by #process_and_next#, the public interface 
-    */
-  virtual void do_process_and_next (Moment until);
-
-
-  virtual Music_iterator* try_music_in_children (Music  *) const;
-  
 public:
   VIRTUAL_COPY_CONS (Music_iterator);
 
-  Music_iterator();
+  Music_iterator ();
   Music_iterator (Music_iterator const&);
-  virtual ~Music_iterator();
-
+  virtual ~Music_iterator ();
 
   /**
      Do the reporting.  Will try MUSIC_L_ in its own translator first,
@@ -77,7 +42,7 @@ public:
   /**
     The translation unit that we this iterator is reporting  to now.
    */
-  Translator_group*report_to_l() const;
+  Translator_group*report_to_l () const;
 
   void set_translator (Translator_group*);
   
@@ -88,11 +53,11 @@ public:
   void init_translator (Music  *, Translator_group *); 
 
   ///  Find the next interesting point in time.
-  virtual Moment next_moment() const;
+  virtual Moment next_moment () const;
 
 
   ///Are we finished with this piece of music?
-  virtual bool ok() const;
+  virtual bool ok () const;
 
   virtual Music* get_music ();
   virtual bool next ();
@@ -104,8 +69,40 @@ public:
     Construct sub-iterators, and set the translator to 
     report to.
    */
-  virtual void construct_children();
-  void print() const;
+  virtual void construct_children ();
+  void print () const;
+
+protected:
+  Music  * music_l_;
+
+  /// ugh. JUNKME
+  bool first_b_;
+
+  /**
+    Do the actual printing.  This should be overriden in derived classes.  It 
+    is called by #print#, in the public interface
+   */
+  virtual void do_print () const;
+    
+  /**
+    Find a bottom notation context to deliver requests to.
+   */
+  virtual Translator_group* get_req_translator_l ();
+
+  /**
+    Get an iterator for MUS, inheriting the translation unit from THIS.
+   */
+  Music_iterator* get_iterator_p (Music *) const;
+
+  /** Do the actual move.  This should be overriden in derived
+    classes.  It is called by #process_and_next#, the public interface 
+    */
+  virtual void do_process_and_next (Moment until);
+
+  virtual Music_iterator* try_music_in_children (Music *) const;
+  
+private:
+  Interpretation_context_handle handle_;
 };
 
 #endif // MUSIC_ITERATOR_HH
index caf7b4dcd7ac4f2250c442f3b5508ae127661c59..d43a00a72daf9d29a95d459242bc27b10e1005a8 100644 (file)
@@ -33,11 +33,8 @@ private:
 
   Music_iterator * first_iter_p_;
   Music_iterator * second_iter_p_;
-  Moment now_;
   Moment first_until_;
   Moment second_until_;
-
-  bool combined_b_;
 };
 
 #endif /* PART_COMBINE_MUSIC_ITERATOR_HH */
index 1fa5bb7d16dfc906501527536858434cfcbdc6c8..324c9b952ab95815af37b5136542e33b910b5de7 100644 (file)
@@ -1,14 +1,13 @@
 /*   
-  request-iterator.hh -- declare Request_iterator
+  simple-music-iterator.hh -- declare Simple_music_iterator
   
   source file of the GNU LilyPond music typesetter
   
   (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  
  */
 
-#ifndef REQUEST_ITERATOR_HH
-#define REQUEST_ITERATOR_HH
+#ifndef SIMPLE_MUSIC_ITERATOR_HH
+#define SIMPLE_MUSIC_ITERATOR_HH
 
 #include "music-iterator.hh"
 
@@ -18,9 +17,10 @@ public:
   VIRTUAL_COPY_CONS (Music_iterator);
   Simple_music_iterator ();
   Simple_music_iterator (Simple_music_iterator const &);
+
 protected:
   virtual void do_process_and_next (Moment );
 };
 
-#endif /* REQUEST_ITERATOR_HH */
+#endif /* SIMPLE_MUSIC_ITERATOR_HH */
 
index b6a403ea2dcd05e64e2324890308993741db2364..e5b056e60180ec94f89f8c7fa8a005d85238dcc2 100644 (file)
 #include "interpretation-context-handle.hh"
 #include "translator-group.hh"
 
+Interpretation_context_handle::Interpretation_context_handle()
+{
+  report_to_l_ =0;
+}
+
+Interpretation_context_handle::Interpretation_context_handle (Interpretation_context_handle const&s)
+{
+  report_to_l_ =0;
+  if (s.report_to_l_)
+    up (s.report_to_l_ );
+}
+
+Interpretation_context_handle*
+Interpretation_context_handle::clone () const
+{
+  Interpretation_context_handle* handle = new Interpretation_context_handle;
+  handle->report_to_l_ = this->report_to_l_;
+  return handle;
+}
+
+Interpretation_context_handle::~Interpretation_context_handle ()
+{
+  if (report_to_l_)
+    down ();
+}
+
 void
 Interpretation_context_handle::up (Translator_group*t)
 {
@@ -31,13 +57,6 @@ Interpretation_context_handle::try_music (Music *m)
   return  report_to_l_->try_music (m);
 }
 
-Interpretation_context_handle::Interpretation_context_handle (Interpretation_context_handle const&s)
-{
-  report_to_l_ =0;
-  if (s.report_to_l_)
-    up (s.report_to_l_ );
-}
-
 void
 Interpretation_context_handle::operator = (Interpretation_context_handle const &s)
 {
@@ -61,14 +80,4 @@ Interpretation_context_handle::report_to_l ()const
   return report_to_l_;
 }
 
-Interpretation_context_handle::Interpretation_context_handle()
-{
-  report_to_l_ =0;
-}
-
-Interpretation_context_handle::~Interpretation_context_handle ()
-{
-  if (report_to_l_)
-    down ();
-}
 
index e0978106daef7787a98aae857d8b91b1524c6380..bae22a94afddb94a0ef6790a871938c043f64bf3 100644 (file)
@@ -49,7 +49,7 @@ Music_iterator::Music_iterator ()
 Music_iterator::Music_iterator (Music_iterator const& src)
 {
   first_b_ = src.first_b_;
-  handle_ = src.handle_;
+  handle_ = *src.handle_.clone ();
   music_l_ = src.music_l_;
 }
 
index 4aa13bd9a24fad357a3a1d7fa9145d27312063b8..396e9c4657aea44f323c2172a5043fe2dd994f96 100644 (file)
@@ -19,7 +19,7 @@ Music_wrapper_iterator::Music_wrapper_iterator ()
 Music_wrapper_iterator::Music_wrapper_iterator (Music_wrapper_iterator const &src)
   : Music_iterator (src)
 {
-  child_iter_p_ = src.child_iter_p_;
+  child_iter_p_ = src.child_iter_p_->clone ();
 }
 
 Music_wrapper_iterator::~Music_wrapper_iterator ()
index ab2ec18b9a0601852f4f84d011ae1fdea063af15..b5c3780961c2b341664119d2b501d10ba938341b 100644 (file)
@@ -15,9 +15,6 @@
 
 Part_combine_music_iterator::Part_combine_music_iterator ()
 {
-  combined_b_ = true;
-
-  now_ = 0;
   first_iter_p_ = 0;
   second_iter_p_ = 0;
   first_until_ = 0;
@@ -123,86 +120,64 @@ Part_combine_music_iterator::do_process_and_next (Moment m)
 {
   Part_combine_music const * p = dynamic_cast<Part_combine_music const* > (music_l_);
 
-  /*
-    TODO:
-
-    * Maybe we need a Skip_engraver?
-
-    (check): can this all be handled now?
-    
-    Maybe different modes exist?
-
-    * Wind instruments (Flute I/II)
-    * Hymnals:  
-
-
-      Rules for Hymnals/SATB (John Henckel <henckel@iname.com>):
-
-      1. if S and A differ by less than a third, the stems should be up/down.
-      2. else if S and A have different values, the stems should be up/down.
-      3. else if A sings "la" or higher, both S and A stems should be down.
-      4. else both stems should be up
-
-    * This may get really tricky: combining voices/staffs: string instruments
-
-   */
-  
-  /*
-    Huh?
-   */
-  now_ = next_moment ();
-  Music *first_music;
-  Music_iterator* first_next = first_iter_p_->clone ();
-  //first_next->next ();
-  if (first_next->ok ())
-    first_music = first_next->get_music ();
-#if 0
-  delete first_next;
-#else
-  //URGURURGU
-  first_next->handle_.down ();
-#endif
-  
-  Music *second_music;
-  Music_iterator* second_next = second_iter_p_->clone ();
-  //second_next->next ();
-  if (second_next->ok ())
-    second_music = second_next->get_music ();
-#if 0
-  delete second_next;
-#else
-  //URGURURGU
-  second_next->handle_.down ();
-#endif
+  Moment now = next_moment ();
 
   Array<Musical_pitch> first_pitches;
   Array<Duration> first_durations;
-  if (Music_sequence* m = dynamic_cast<Music_sequence *> (first_music))
+  if (first_iter_p_->ok ())
     {
-      for (SCM s = m->music_list (); gh_pair_p (s);  s = gh_cdr (s))
+      Music_iterator* i = first_iter_p_->clone ();
+      Moment until = i->next_moment ();
+
+      /* Urg, silly first_b_ stuff */
+      if (now && i->next ())
+       until = i->next_moment ();
+
+      /* How about a 'now_moment ()' for iterators? */
+      for (; i->ok () && i->next_moment () == until; i->next ())
        {
-         Music *u = unsmob_music (gh_car (s));
-         if (Melodic_req *r = dynamic_cast<Melodic_req *> (u))
-           first_pitches.push (r->pitch_);
-         if (Rhythmic_req *r = dynamic_cast<Rhythmic_req *> (u))
-           first_durations.push (r->duration_);
+         if (Music_sequence* m = dynamic_cast<Music_sequence *> (i->get_music ()))
+           {
+             for (SCM s = m->music_list (); gh_pair_p (s);  s = gh_cdr (s))
+               {
+                 Music *u = unsmob_music (gh_car (s));
+                 if (Melodic_req *r = dynamic_cast<Melodic_req *> (u))
+                   first_pitches.push (r->pitch_);
+                 if (Rhythmic_req *r = dynamic_cast<Rhythmic_req *> (u))
+                   first_durations.push (r->duration_);
+               }
+           }
        }
     }
 
   Array<Musical_pitch> second_pitches;
   Array<Duration> second_durations;
-  if (Music_sequence* m = dynamic_cast<Music_sequence *> (second_music))
+  if (second_iter_p_->ok ())
     {
-      for (SCM s = m->music_list (); gh_pair_p (s);  s = gh_cdr (s))
+      Music_iterator* i = second_iter_p_->clone ();
+      Moment until = i->next_moment ();
+
+      /* Urg, silly second_b_ stuff */
+      if (now && i->next ())
+       until = i->next_moment ();
+
+      /* How about a 'now_moment ()' for iterators? */
+      for (; i->ok () && i->next_moment () == until; i->next ())
        {
-         Music *u = unsmob_music (gh_car (s));
-         if (Melodic_req *r = dynamic_cast<Melodic_req *> (u))
-           second_pitches.push (r->pitch_);
-         if (Rhythmic_req *r = dynamic_cast<Rhythmic_req *> (u))
-           second_durations.push (r->duration_);
+         if (Music_sequence* m = dynamic_cast<Music_sequence *> (i->get_music ()))
+           {
+             for (SCM s = m->music_list (); gh_pair_p (s);  s = gh_cdr (s))
+               {
+                 Music *u = unsmob_music (gh_car (s));
+                 if (Melodic_req *r = dynamic_cast<Melodic_req *> (u))
+                   second_pitches.push (r->pitch_);
+                 if (Rhythmic_req *r = dynamic_cast<Rhythmic_req *> (u))
+                   second_durations.push (r->duration_);
+               }
+           }
        }
     }
-
+  
   SCM interval = SCM_BOOL_F;
   if (first_pitches.size () && second_pitches.size ())
     {
@@ -214,7 +189,7 @@ Part_combine_music_iterator::do_process_and_next (Moment m)
   if (first_durations.size ())
     {
       first_durations.sort (Duration::compare);
-      Moment new_until = now_ + first_durations.top ().length_mom ();
+      Moment new_until = now + first_durations.top ().length_mom ();
       if (new_until > first_until_)
        first_until_ = new_until;
     }
@@ -222,16 +197,31 @@ Part_combine_music_iterator::do_process_and_next (Moment m)
     if (second_durations.size ())
     {
       second_durations.sort (Duration::compare);
-      Moment new_until = now_ + second_durations.top ().length_mom ();
+      Moment new_until = now + second_durations.top ().length_mom ();
       if (new_until > second_until_)
        second_until_ = new_until;
     }
 
+#if 0 /* DEBUG */
+  printf ("now: %s\n", now.str ().ch_C ());
+  printf ("first: ");
+  for (int i = 0; i < first_pitches.size (); i++)
+    {
+      printf ("%s, ", first_pitches[i].str ().ch_C ());
+    }
+  printf ("\nsecond: ");
+  for (int i = 0; i < second_pitches.size (); i++)
+    {
+      printf ("%s, ", second_pitches[i].str ().ch_C ());
+    }
+  printf ("\n");
+#endif
+
   Translator_group * fir = first_iter_p_->report_to_l ();
   Translator_group * sir = second_iter_p_->report_to_l ();
 
   bool solo_b = (first_pitches.empty () != second_pitches.empty ())
-    && !(first_until_ > now_ && second_until_ > now_);
+    && !(first_until_ > now && second_until_ > now);
 
   bool unirhythm_b = !solo_b && !compare (&first_durations, &second_durations);
   bool unison_b = unirhythm_b && !first_pitches.empty ()
@@ -254,26 +244,23 @@ Part_combine_music_iterator::do_process_and_next (Moment m)
        split_interval_b = true;
     }
 
-  /*
-    URG, dememberme
-   */
-  combined_b_ = first_iter_p_->report_to_l ()->daddy_trans_l_
+  bool combined_b = first_iter_p_->report_to_l ()->daddy_trans_l_
     == second_iter_p_->report_to_l ()->daddy_trans_l_;
 
-  String to_id =  combined_b_ ? "one" : "two";
-  if ((!unirhythm_b && combined_b_)
-      || (split_interval_b && combined_b_)
-      || (solo_b && combined_b_)
-      /*|| (unisilence_b && combined_b_) */
+  String to_id =  combined_b ? "one" : "two";
+  if ((!unirhythm_b && combined_b)
+      || (split_interval_b && combined_b)
+      || (solo_b && combined_b)
+      /*|| (unisilence_b && combined_b) */
       || ((unirhythm_b || unison_b || unisilence_b)
-         && !combined_b_ && !split_interval_b && !solo_b))
+         && !combined_b && !split_interval_b && !solo_b))
     {
-      combined_b_ = !combined_b_;
-      to_id =  combined_b_ ? "one" : "two";
+      combined_b = !combined_b;
+      to_id =  combined_b ? "one" : "two";
       change_to (second_iter_p_, p->what_str_, to_id);
     }
 
-  if (!combined_b_)
+  if (!combined_b)
     sir = second_iter_p_->report_to_l ();
 
   SCM b = unirhythm_b ? SCM_BOOL_T : SCM_BOOL_F;
@@ -315,7 +302,6 @@ Part_combine_music_iterator::do_process_and_next (Moment m)
     second_iter_p_->process_and_next (m);
 
   Music_iterator::do_process_and_next (m);
-  now_ = next_moment ();
 }
 
 Music_iterator*
index 61e38b309492ed69953456fe794f635a9936e136..f7ae404b922bacdda23d47989564c2b781f1541f 100644 (file)
@@ -64,17 +64,22 @@ Request_chord_iterator::do_print() const
 bool
 Request_chord_iterator::next ()
 {
-  first_b_ = false;
-  //  last_b_ = true;
+  if (first_b_)
+    first_b_ = false;
+  else
+    last_b_ = true;
   return ok ();
 }
 
 void
 Request_chord_iterator::do_process_and_next (Moment mom)
 {
+#if 0
   // URG
-  //  if (ok ())
-  if (first_b_)
+  //if (first_b_)
+#else
+  if (ok ())
+#endif
     {
       for (SCM s = dynamic_cast<Music_sequence *> (get_music ())->music_list (); gh_pair_p (s);  s = gh_cdr (s))
        {
@@ -92,8 +97,9 @@ Request_chord_iterator::do_process_and_next (Moment mom)
     }
 
   next ();
+#if 0
   // URG
   if (mom >= elt_length_mom_)
     last_b_ = true;
-
+#endif
 }
index 3e89e02522bf74d0181c67eb2b158e89b31dcda3..8ba2fa20db418aeca4c9880c98fae5f94deec8f3 100644 (file)
@@ -24,7 +24,7 @@ Sequential_music_iterator::Sequential_music_iterator (Sequential_music_iterator
 {
   cursor_ = src.cursor_;
   here_mom_ = src.here_mom_;
-  iter_p_ = src.iter_p_;
+  iter_p_ = src.iter_p_->clone ();
 }
 
 Sequential_music_iterator::~Sequential_music_iterator()
index dc1b92025a894ecdba9ee986d3ce2dcac5811ad4..94905795cf3ac22fafc29b130d032ce9395f68d5 100644 (file)
@@ -33,7 +33,8 @@ Translator_group::properties_dict () const
 
 Translator_group::~Translator_group ()
 {
-  assert (removable_b());
+  
+  //assert (removable_b());
 }