]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.3.78.jcn1
authorJan Nieuwenhuizen <janneke@gnu.org>
Mon, 14 Aug 2000 18:55:10 +0000 (20:55 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Mon, 14 Aug 2000 18:55:10 +0000 (20:55 +0200)
1.3.78.jcn1
===========

* Fixed a2-devnull-engraver, a2-engraver.

* Renamed part combiner music names to "one", "two".

* Cleaned up property setting of part combiner, renamed to "solo"/"unison"

CHANGES
VERSION
input/test/part-combine.ly
lily/a2-devnull-engraver.cc
lily/a2-engraver.cc
lily/chord.cc
lily/include/musical-pitch.hh
lily/include/part-combine-music-iterator.hh
lily/musical-pitch.cc
lily/part-combine-music-iterator.cc
lily/part-combine-music.cc

diff --git a/CHANGES b/CHANGES
index d46d267c6c9111d131da8ca37196476e3332e48c..983fbc6e78d548906108a3f698e558fdc5c90ab4 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,13 @@
+1.3.78.jcn1
+===========
+
+* Fixed a2-devnull-engraver, a2-engraver.
+
+* Renamed part combiner music names to "one", "two".
+
+* Cleaned up property setting of part combiner, renamed to "solo"/"unison"
+
+
 1.3.77.jcn5
 ===========
 
diff --git a/VERSION b/VERSION
index ba678f5afed7735e903d6c9f2407af15bbb8bf81..c1932a964572ccf0c22983bd6c6efb6f27e84eef 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=3
 PATCH_LEVEL=78
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=jcn1
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
index 074498488ee796903089430d760f4cdd13a004c1..1213e9d1a92ebad244d74f1f550c8af281b20cc8 100644 (file)
@@ -1,19 +1,19 @@
 \score{
-       \context Staff = first <
-               \context Voice=first { \skip 1; }
-               \context Voice=second { \skip 1; }
+       \context Staff = one <
+               \context Voice=one { \skip 1; }
+               \context Voice=two { \skip 1; }
 
-               \context Voice=first \partcombine Voice
-                       \context Thread=first \notes\relative c''
+               \context Voice=one \partcombine Voice
+                       \context Thread=one \notes\relative c''
                                {
                                        c4 d e f
                                        b,4 d c d
                                        r2 e4 f
                                        c4 d e f
                                }
-                       \context Thread=second \notes\relative c''
+                       \context Thread=two \notes\relative c''
                                {
-                                       a b c d
+                                       g b d f
                                        r2 c4 d
                                        a c c d
                                        a4. b8 c4 d
index 680dedb5a326658b16aa08b9e39823f9338d34f9..e0f95453334cba794430ade0653132e9c2c4c386 100644 (file)
@@ -17,25 +17,15 @@ public:
   VIRTUAL_COPY_CONS (Translator);
   
 protected:
-  virtual bool do_try_music (Music*);
+  virtual void acknowledge_element (Score_element_info);
 };
 
 ADD_THIS_TRANSLATOR (A2_devnull_engraver);
 
-bool
-A2_devnull_engraver::do_try_music (Music *m) 
+void
+A2_devnull_engraver::acknowledge_element (Score_element_info i)
 {
-  if (Note_req * n = dynamic_cast <Note_req *> (m))
-    {
-      SCM a2 = get_property ("a2");
-      // should be able to read id_str_, no?
-      SCM second = get_property ("second");
-
-      if (a2 == SCM_BOOL_T && second == SCM_BOOL_T)
-       {
-         return true;
-       }
-    }
-  return false;
+  if (daddy_trans_l_->id_str_ == "two"
+      && to_boolean (get_property ("unison")))
+    i.elem_l_->suicide ();
 }
-      
index 65a239e03029c3b08cbb42ccd76e0c225e500a86..2aedb05b2003ffcc8c863a7340775d2ee82b5161 100644 (file)
@@ -23,12 +23,12 @@ public:
 protected:
   virtual void do_process_music ();
   virtual void acknowledge_element (Score_element_info);
-  //virtual void process_acknowledged ();
 
   virtual void do_pre_move_processing ();
 
 private:
   Item* text_p_;
+  enum State { NORMAL, UNISON, SOLO } state_;
 };
 
 ADD_THIS_TRANSLATOR (A2_engraver);
@@ -36,18 +36,25 @@ ADD_THIS_TRANSLATOR (A2_engraver);
 A2_engraver::A2_engraver ()
 {
   text_p_ = 0;
+  state_ = NORMAL;
 }
 
 void
 A2_engraver::do_process_music ()
+{
+}
+
+
+void
+A2_engraver::acknowledge_element (Score_element_info i)
 {
   if (!text_p_)
     {
-      SCM a2 = get_property ("a2");
+      SCM unison = get_property ("unison");
       SCM solo = get_property ("solo");
-      SCM solo2 = get_property ("solo2");
 
-      if (solo == SCM_BOOL_T || a2 == SCM_BOOL_T || solo2 == SCM_BOOL_T)
+      if ((solo == SCM_BOOL_T && state_ != SOLO)
+         || (unison == SCM_BOOL_T && state_ != UNISON))
        {
          text_p_ = new Item (get_property ("basicTextScriptProperties"));
          Side_position::set_axis (text_p_, Y_AXIS);
@@ -60,28 +67,33 @@ A2_engraver::do_process_music ()
          Direction dir = UP;
          if (solo == SCM_BOOL_T)
            {
-             text = ly_str02scm ("Solo");
-           }
-         else if (solo2 == SCM_BOOL_T)
-           {
-             text = ly_str02scm ("Solo II");
-             dir = DOWN;
+             state_ = SOLO;
+             if (daddy_trans_l_->id_str_ == "one")
+               text = ly_str02scm ("Solo");
+             else
+               {
+                 text = ly_str02scm ("Solo II");
+                 dir = DOWN;
+               }
            }
-         else if (a2 == SCM_BOOL_T)
+         else if (unison == SCM_BOOL_T)
            {
              text = ly_str02scm ("\\`a 2");
+             state_ = UNISON;
            }
-
+         
          Side_position::set_direction (text_p_, dir);
          text_p_->set_elt_property ("text", text);
 
        }
     }
+#if 0
 }
 
 void
 A2_engraver::acknowledge_element (Score_element_info i)
 {
+#endif
   if (text_p_)
     {
       if (Note_head::has_interface (i.elem_l_))
@@ -95,26 +107,39 @@ A2_engraver::acknowledge_element (Score_element_info i)
       if (Stem::has_interface (i.elem_l_))
        {
          Side_position::add_support (text_p_, i.elem_l_);
+       }
+    }
          
-         SCM a2 = get_property ("a2");
-         SCM solo = get_property ("solo");
-         SCM solo2 = get_property ("solo2");
-
-         SCM first = get_property ("first");
-         SCM second = get_property ("second");
-
-         if (solo != SCM_BOOL_T
-             && solo2 != SCM_BOOL_T
-             && a2 != SCM_BOOL_T)
+         
+  if (Stem::has_interface (i.elem_l_))
+    {
+      SCM unirhythm = get_property ("unirhythm");
+      SCM unison = get_property ("unison");
+      SCM solo = get_property ("solo");
+      SCM interval = get_property ("interval");
+
+      /*
+       This still needs some work.
+       */
+      if ((unirhythm != SCM_BOOL_T && solo != SCM_BOOL_T))
+#if 0
+       /*
+         Apart from the uglyness of this, we can't do this yet
+         because to get up/down stems for small intervals, we
+         need Part_combine_music_iterator to uncombine the
+         voices (while still setting unison).
+        */
+         || (unirhythm == SCM_BOOL_T
+             && gh_number_p (interval) && gh_scm2int (interval) < 3))
+#endif
+       {
+         if (daddy_trans_l_->id_str_ == "one")
            {
-             if (first == SCM_BOOL_T)
-               {
-                 Directional_element_interface (i.elem_l_).set (UP);
-               }
-             else if (second == SCM_BOOL_T)
-               {
-                 Directional_element_interface (i.elem_l_).set (DOWN);
-               }
+             Directional_element_interface (i.elem_l_).set (UP);
+           }
+         else if (daddy_trans_l_->id_str_ == "two")
+           {
+             Directional_element_interface (i.elem_l_).set (DOWN);
            }
        }
     }
@@ -129,9 +154,5 @@ A2_engraver::do_pre_move_processing ()
       typeset_element (text_p_);
       text_p_ = 0;
     }
-  // burp: reset properties
-  daddy_trans_l_->set_property ("a2", SCM_BOOL_F);
-  daddy_trans_l_->set_property ("solo", SCM_BOOL_F);
-  daddy_trans_l_->set_property ("solo2", SCM_BOOL_F);
 }
 
index 6c858167262d77800362841d123c32436a0398b6..ef1c58a66f49cad4d7bcaa71967e3b5d5aa4d7e9 100644 (file)
@@ -13,6 +13,7 @@
 #include "molecule.hh"
 #include "paper-def.hh"
 #include "lookup.hh"
+#include "lookup.hh"
 
 int
 compare (Chord* left, Chord* right)
@@ -20,17 +21,9 @@ compare (Chord* left, Chord* right)
   assert (left);
   assert (right);
   
-  if (left->inversion_b_ == right->inversion_b_
-      && left->bass_b_ == right->bass_b_
-      && left->pitch_arr_.size () == right->pitch_arr_.size ())
-    {
-      for (int i = 0; i < left->pitch_arr_.size (); i++)
-       if (left->pitch_arr_[i] != right->pitch_arr_[i])
-         return 1;
-      return 0;
-    }
-  
-  return 1;
+  return !(left->inversion_b_ == right->inversion_b_
+          && left->bass_b_ == right->bass_b_
+          && !compare (&left->pitch_arr_, &right->pitch_arr_));
 }
 
 /*
index 7f2c386b4d71b85020af474a1000089f1814ec94..079de76c8f650127501de88e1a6d82c7bdccc512 100644 (file)
@@ -53,5 +53,7 @@ struct Musical_pitch : public Input
 #include "compare.hh"
 INSTANTIATE_COMPARE(Musical_pitch, Musical_pitch::compare);
 
+int compare (Array<Musical_pitch>*, Array<Musical_pitch>*);
+
 #endif /* MUSICAL_PITCH_HH */
 
index 60cbebc8fc47b4d3754baa0d43c9fc91c4ac4848..dcf86214e86e522912c056fe05ce31c96a8ecbac 100644 (file)
@@ -33,7 +33,7 @@ private:
   Music_iterator * first_iter_p_;
   Music_iterator * second_iter_p_;
 
-  bool combined_b_;
+  bool unirhythm_b_;
 };
 
 #endif /* PART_COMBINE_MUSIC_ITERATOR_HH */
index 0ebd91dfe4139d94bcc2c02dbb60c610ed0878fb..5e82e01c7b2ee30e73e68c77353f8adbff537722 100644 (file)
 #include "debug.hh"
 #include "main.hh"
 
+int
+compare (Array<Musical_pitch>* left, Array<Musical_pitch>* right)
+{
+  assert (left);
+  assert (right);
+  
+  if (left->size () == right->size ())
+    {
+      for (int i = 0; i < left->size (); i++)
+       if ((*left)[i] != (*right)[i])
+         return 1;
+    }
+  return 0;
+}
+
 SCM
 Musical_pitch::to_scm ()const
 {
index 86f035486bb1c9a303352bae6b98d0ef01a321c7..6933b2bd1c3eed751bb9e48d2a2b9ac6059a111d 100644 (file)
@@ -14,7 +14,7 @@
 
 Part_combine_music_iterator::Part_combine_music_iterator ()
 {
-  combined_b_ = false;
+  unirhythm_b_ = false;
 
   first_iter_p_ = 0;
   second_iter_p_ = 0;
@@ -117,32 +117,40 @@ Part_combine_music_iterator::do_process_and_next (Moment m)
   Moment first_next = first_iter_p_->next_moment ();
   Moment second_next = second_iter_p_->next_moment ();
 
-  bool changed_b = false;
   Part_combine_music const * p = dynamic_cast<Part_combine_music const* > (music_l_);
 
-  String to_id =  combined_b_ ? "first" : "second";
+  String to_id =  unirhythm_b_ ? "one" : "two";
   /*
     different rhythm for combined voices: separate 
     same rhythm for separated voices: combine
+
+    Arg.  Voices should be separated for small intervals, eg < 3.
+    This should be \property settable, and, we need the outcome
+    of the spanish_inquisition's...
+
+    Can't we first do a process_and_next go into a fake/tmp tree,
+    use + junk the result, and then do the real process_and_next...?
+    
   */
-  if ((first_next != second_next && combined_b_)
-      || (first_next == second_next && !combined_b_))
+  if ((first_next != second_next && unirhythm_b_)
+      || (first_next == second_next && !unirhythm_b_))
     {
-      combined_b_ = !combined_b_;
-      to_id =  combined_b_ ? "first" : "second";
+      unirhythm_b_ = !unirhythm_b_;
+      to_id =  unirhythm_b_ ? "one" : "two";
       change_to (second_iter_p_, p->what_str_, to_id);
-      changed_b = true;
     }
 
   Translator_group * fd = 
     first_iter_p_->report_to_l ()->find_create_translator_l (p->what_str_,
-                                                            "first");
+                                                            "one");
   Translator_group * sd = 
     second_iter_p_->report_to_l ()->find_create_translator_l (p->what_str_,
                                                              to_id);
 
-  fd->set_property ("first", SCM_BOOL_T);
-  sd->set_property ("second", SCM_BOOL_T);
+  fd->set_property ("unirhythm", unirhythm_b_ ? SCM_BOOL_T : SCM_BOOL_F);
+  sd->set_property ("unirhythm", unirhythm_b_ ? SCM_BOOL_T : SCM_BOOL_F);
+  first_iter_p_->report_to_l ()->set_property ("unirhythm", unirhythm_b_ ? SCM_BOOL_T : SCM_BOOL_F);
+  second_iter_p_->report_to_l ()->set_property ("unirhythm", unirhythm_b_ ? SCM_BOOL_T : SCM_BOOL_F);
 
   if (first_next <= m)
     first_iter_p_->process_and_next (m);
@@ -155,23 +163,17 @@ Part_combine_music_iterator::do_process_and_next (Moment m)
   /*
     TODO:
     
-    * "a2" string is fine, but "Soli" strings are one request late,
-      second a2 requests are junked one requst late...
+    * "a2" string is fine, but "Soli" strings are one request late??
     
       The problem seems to be: we need to do_try_music for the
       spanish_inquisition to work; but the properties that we set
       need to be set *before* we do_try_music?
       
     * setting of stem directions by a2-engraver don't work
-      
-    * move much as possible code (changed?) to engravers: just notify
-      them of status: unison/solo.  Engravers should be able to find
-      out whether something changed and if so, what to do.
-
-    * who should reset the properties, it's a mess now?
-
 
-    Later (because currently,we only handle thread swiching, really):
+    * separate for small ( <3 ?) intervals too
+      
+    Later (because currently, we only handle thread switching, really):
 
     Maybe different modes exist?
 
@@ -198,39 +200,59 @@ Part_combine_music_iterator::do_process_and_next (Moment m)
     second_spanish_inquisition = new Pitch_interrogate_req;
   Music_iterator* sit = second_iter_p_->try_music (second_spanish_inquisition);
 
-
-  // URG, moveme: just set properties
-  if (//changed_b
-      //&&
-      (first_next == second_next)
-      && first_spanish_inquisition->pitch_arr_.size ()
-      && (first_spanish_inquisition->pitch_arr_.size ()
-         == second_spanish_inquisition->pitch_arr_.size ())
-      && (first_spanish_inquisition->pitch_arr_[0] ==
-         second_spanish_inquisition->pitch_arr_[0]))
+  if ((first_next == second_next)
+      && !compare (&first_spanish_inquisition->pitch_arr_,
+                  &second_spanish_inquisition->pitch_arr_))
     {
-      if (changed_b)
-       {
-         fd->set_property ("a2", SCM_BOOL_T);
-         sd->set_property ("a2", SCM_BOOL_T);
-       }
-      second_iter_p_->report_to_l ()->set_property ("a2", SCM_BOOL_T);
+      fd->set_property ("unison", SCM_BOOL_T);
+      sd->set_property ("unison", SCM_BOOL_T);
+      first_iter_p_->report_to_l ()->set_property ("unison", SCM_BOOL_T);
+      second_iter_p_->report_to_l ()->set_property ("unison", SCM_BOOL_T);
     }
   else
-    second_iter_p_->report_to_l ()->set_property ("a2", SCM_BOOL_F);
-  
-  if (changed_b
-      && first_spanish_inquisition->pitch_arr_.size ()
+    {
+      fd->set_property ("unison", SCM_BOOL_F);
+      sd->set_property ("unison", SCM_BOOL_F);
+      first_iter_p_->report_to_l ()->set_property ("unison", SCM_BOOL_F);
+      second_iter_p_->report_to_l ()->set_property ("unison", SCM_BOOL_F);
+    }
+
+  if (first_spanish_inquisition->pitch_arr_.size () &&
+      second_spanish_inquisition->pitch_arr_.size ())
+    {
+      first_spanish_inquisition->pitch_arr_.sort (Musical_pitch::compare);
+      second_spanish_inquisition->pitch_arr_.sort (Musical_pitch::compare);
+      SCM interval = gh_int2scm (first_spanish_inquisition->pitch_arr_.top ().semitone_pitch ()
+                                - second_spanish_inquisition->pitch_arr_[0].semitone_pitch ());
+      fd->set_property ("interval", interval);
+      sd->set_property ("interval", interval);
+      first_iter_p_->report_to_l ()->set_property ("interval", interval);
+      second_iter_p_->report_to_l ()->set_property ("interval", interval);
+    }
+      
+  if (first_spanish_inquisition->pitch_arr_.size ()
       && !second_spanish_inquisition->pitch_arr_.size ())
     {
       fd->set_property ("solo", SCM_BOOL_T);
+      first_iter_p_->report_to_l ()->set_property ("solo", SCM_BOOL_T);
     }
+  else
+    {
+      fd->set_property ("solo", SCM_BOOL_F);
+      first_iter_p_->report_to_l ()->set_property ("solo", SCM_BOOL_F);
+    }
+
 
-  if (changed_b
-      && !first_spanish_inquisition->pitch_arr_.size ()
+  if (!first_spanish_inquisition->pitch_arr_.size ()
       && second_spanish_inquisition->pitch_arr_.size ())
     {
-      sd->set_property ("solo2", SCM_BOOL_T);
+      sd->set_property ("solo", SCM_BOOL_T);
+      second_iter_p_->report_to_l ()->set_property ("solo", SCM_BOOL_T);
+    }
+  else
+    {
+      sd->set_property ("solo", SCM_BOOL_F);
+      second_iter_p_->report_to_l ()->set_property ("solo", SCM_BOOL_F);
     }
 
   first_spanish_inquisition->pitch_arr_.clear ();
index 41127ac7419d3b6c83157b4a6d3b51ed19a2385a..27064244b7628996c83685b30524affc92cf8581 100644 (file)
@@ -13,8 +13,8 @@
 Part_combine_music::Part_combine_music (String what, Music * f, Music * s)
 {
   what_str_ = what;
-  set_mus_property ("first", f->self_scm ());
-  set_mus_property ("second", s->self_scm ());  
+  set_mus_property ("one", f->self_scm ());
+  set_mus_property ("two", s->self_scm ());  
 }
 
 
@@ -55,11 +55,11 @@ Part_combine_music::compress (Moment m)
 Music*
 Part_combine_music::first_l () const
 {
-  return unsmob_music (get_mus_property ("first"));
+  return unsmob_music (get_mus_property ("one"));
 }
 
 Music*
 Part_combine_music::second_l () const
 {
-  return unsmob_music (get_mus_property ("second"));
+  return unsmob_music (get_mus_property ("two"));
 }