]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/part-combine-music-iterator.cc
* Documentation/windows/zlily-profile.sh:
[lilypond.git] / lily / part-combine-music-iterator.cc
index 526b70ab88815ea1e94bf42bbc0ec9d4fbecffeb..3e0fccef6e5e559ac7d274ba85ff1ee8931c3938 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
   
-  (c) 2000 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 2000--2002 Jan Nieuwenhuizen <janneke@gnu.org>
  */
 
 #include "part-combine-music.hh"
@@ -62,7 +62,7 @@ Part_combine_music_iterator::ok () const
 void
 Part_combine_music_iterator::construct_children ()
 {
-  Part_combine_music const * m = dynamic_cast<Part_combine_music const*> (music_l_);
+  Part_combine_music const * m = dynamic_cast<Part_combine_music const*> (music_l ());
   
   first_iter_p_ = get_iterator_p (m->first_l ());
   second_iter_p_ = get_iterator_p (m->second_l ());
@@ -85,7 +85,7 @@ Part_combine_music_iterator::change_to (Music_iterator *it, String to_type,
      
      If \translator Staff = bass, then look for Staff = *
    */
-  while  (current && current->type_str_ != to_type)
+  while (current && current->type_str_ != to_type)
     {
       last = current;
       current = current->daddy_trans_l_;
@@ -103,7 +103,7 @@ Part_combine_music_iterator::change_to (Music_iterator *it, String to_type,
        Translator_group * dest = 
          it->report_to_l ()->find_create_translator_l (to_type, to_id);
        current->remove_translator_p (last);
-       dest->add_group_translator (last);
+       dest->add_used_group_translator (last);
       }
     else
       {
@@ -126,13 +126,20 @@ get_music_info (Moment m, Music_iterator* iter, SCM *pitches, SCM *durations)
 {
   if (iter->ok ())
     {
-      for (SCM i = iter->get_music (m); gh_pair_p (i); i = gh_cdr (i))
+      for (SCM i = iter->get_music (m); gh_pair_p (i); i = ly_cdr (i))
        {
-         Music *m = unsmob_music (gh_car (i));
+         Music *m = unsmob_music (ly_car (i));
          if (Melodic_req *r = dynamic_cast<Melodic_req *> (m))
-           *pitches = gh_cons (r->get_mus_property("pitch"), *pitches);
+           *pitches = gh_cons (r->get_mus_property ("pitch"), *pitches);
          if (Rhythmic_req *r = dynamic_cast<Rhythmic_req *> (m))
-           *durations = gh_cons (r->get_mus_property("duration"), *durations);
+           {
+             SCM d = r->get_mus_property ("duration");
+             if (d == SCM_EOL)
+               r->origin ()->warning ("Rhythmic_req has no duration\n");
+               else
+                 // *durations = gh_cons (r->get_mus_property ("duration"), *durations);
+                 *durations = gh_cons (d, *durations);
+           }
        }
     }
 }
@@ -141,23 +148,23 @@ int
 Part_combine_music_iterator::get_state (Moment)
 {
   int state = UNKNOWN;
-  Part_combine_music const *p = dynamic_cast<Part_combine_music const* > (music_l_);
+  Part_combine_music const *p = dynamic_cast<Part_combine_music const* > (music_l ());
 
   String w = ly_scm2string (p->get_mus_property ("what"));
     
   
   Translator_group *first_translator = first_iter_p_->report_to_l ()->find_create_translator_l (w, "one" + suffix_);
 
-  SCM s = first_translator->get_property (ly_symbol2scm ("changeMoment"));
+  SCM s = first_translator->get_property ("changeMoment");
   if (!gh_pair_p (s))
     return state;
 
-  Moment change_mom = *unsmob_moment (gh_car (s));
-  Moment diff_mom = *unsmob_moment (gh_cdr (s));
+  Moment change_mom = *unsmob_moment (ly_car (s));
+  Moment diff_mom = *unsmob_moment (ly_cdr (s));
   
   Moment now = pending_moment ();
 
-  if (!now.mod_rat (change_mom))
+  if (!now.main_part_.mod_rat (change_mom.main_part_))
     {
       SCM interval = SCM_BOOL_F;
       if (first_until_ < now)
@@ -202,48 +209,45 @@ Part_combine_music_iterator::get_state (Moment)
          if (first_pitches != SCM_EOL && second_pitches != SCM_EOL)
            {
              scm_sort_list_x (first_pitches,
-                              scm_eval2 (ly_str02scm ("Pitch::less_p"),
-                                         SCM_EOL));
+                              scm_primitive_eval (ly_symbol2scm ("Pitch::less_p")));
              scm_sort_list_x (second_pitches,
-                              scm_eval2 (ly_str02scm ("Pitch::less_p"),
-                                         SCM_EOL));
-             interval = gh_int2scm (unsmob_pitch (gh_car (first_pitches))->steps ()
-                                    - unsmob_pitch (gh_car (scm_last_pair (second_pitches)))->steps ());
+                              scm_primitive_eval (ly_symbol2scm ("Pitch::less_p")));
+
+             interval = gh_int2scm (unsmob_pitch (ly_car (first_pitches))->steps ()
+                                    - unsmob_pitch (ly_car (scm_last_pair (second_pitches)))->steps ());
            }
-         
+
          if (first_durations != SCM_EOL)
            {
              scm_sort_list_x (first_durations,
-                              scm_eval2 (ly_str02scm ("Duration::less_p"),
-                                         SCM_EOL));
-             first_mom += unsmob_duration (gh_car (first_durations))->length_mom ();
+                              scm_primitive_eval (ly_symbol2scm ("Duration::less_p")));
+             first_mom += unsmob_duration (ly_car (first_durations))->length_mom ();
            }
          
          if (second_durations != SCM_EOL)
            {
              scm_sort_list_x (second_durations,
-                              scm_eval2 (ly_str02scm ("Duration::less_p"),
-                                         SCM_EOL));
-             second_mom += unsmob_duration (gh_car (second_durations))->length_mom ();
+                              scm_primitive_eval (ly_symbol2scm ("Duration::less_p")));
+             second_mom += unsmob_duration (ly_car (second_durations))->length_mom ();
            }
          
          if (first_pitches != SCM_EOL && second_pitches == SCM_EOL
-                 && !(second_until_ > now))
+                 && ! (second_until_ > now))
            {
              state |= UNRELATED;
              state &= ~UNISILENCE;
-             if (!(state & ~(UNRELATED | SOLO1 | UNISILENCE)))
+             if (! (state & ~ (UNRELATED | SOLO1 | UNISILENCE)))
                state |= SOLO1;
            }
          else
            state &= ~SOLO1;
 
          if (first_pitches == SCM_EOL && second_pitches != SCM_EOL
-             && !(first_until_ > now))
+             && ! (first_until_ > now))
            {
              state |= UNRELATED;
              state &= ~UNISILENCE;
-             if (!(state & ~(UNRELATED | SOLO2 | UNISILENCE)))
+             if (! (state & ~ (UNRELATED | SOLO2 | UNISILENCE)))
                state |= SOLO2;
            }
          else
@@ -252,47 +256,47 @@ Part_combine_music_iterator::get_state (Moment)
          if (gh_equal_p (first_durations, second_durations))
            {
              state &= ~UNISILENCE;
-             if (!(state & ~(UNIRHYTHM | UNISON)))
+             if (! (state & ~ (UNIRHYTHM | UNISON)))
                state |= UNIRHYTHM;
            }
          else
-           state &= ~(UNIRHYTHM | UNISILENCE);
+           state &= ~ (UNIRHYTHM | UNISILENCE);
          
          if (first_pitches != SCM_EOL
              && gh_equal_p (first_pitches, second_pitches))
            {
              state &= ~UNISILENCE;
-             if (!(state & ~(UNIRHYTHM | UNISON)))
+             if (! (state & ~ (UNIRHYTHM | UNISON)))
                state |= UNISON;
            }
          else
-           state &= ~(UNISON);
+           state &= ~ (UNISON);
            
          if (first_pitches == SCM_EOL && second_pitches == SCM_EOL)
            {
-             if (!(state & ~(UNIRHYTHM | UNISILENCE)))
+             if (! (state & ~ (UNIRHYTHM | UNISILENCE)))
                state |= UNISILENCE;
            }
          else if (!state)
            state |= UNRELATED;
          else
-           state &= ~(UNISILENCE);
+           state &= ~ (UNISILENCE);
 
          if (gh_number_p (interval))
            {
-             SCM s = first_translator->get_property (ly_symbol2scm ("splitInterval"));
+             SCM s = first_translator->get_property ("splitInterval");
              int i = gh_scm2int (interval);
              if (gh_pair_p (s)
-                 && gh_number_p (gh_car (s))
-                 && gh_number_p (gh_cdr (s))
-                 && i >= gh_scm2int (gh_car (s))
-                 && i <= gh_scm2int (gh_cdr (s)))
+                 && gh_number_p (ly_car (s))
+                 && gh_number_p (ly_cdr (s))
+                 && i >= gh_scm2int (ly_car (s))
+                 && i <= gh_scm2int (ly_cdr (s)))
                {
-                 if (!(state & ~(SPLIT_INTERVAL | UNIRHYTHM | UNISON)))
+                 if (! (state & ~ (SPLIT_INTERVAL | UNIRHYTHM | UNISON)))
                    state |= SPLIT_INTERVAL;
                }
              else
-               state &= ~(SPLIT_INTERVAL);
+               state &= ~ (SPLIT_INTERVAL);
            }
 
          if (first && first_pitches != SCM_EOL)
@@ -341,7 +345,7 @@ Part_combine_music_iterator::process (Moment m)
   else
     state = state_;
   
-  Part_combine_music const *p = dynamic_cast<Part_combine_music const* > (music_l_);
+  Part_combine_music const *p = dynamic_cast<Part_combine_music const* > (music_l ());
 
 
   bool previously_combined_b = first_iter_p_->report_to_l ()->daddy_trans_l_
@@ -349,7 +353,7 @@ Part_combine_music_iterator::process (Moment m)
 
   bool combine_b = previously_combined_b;
 
-  if (!(state & UNIRHYTHM)
+  if (! (state & UNIRHYTHM)
       || (state & SPLIT_INTERVAL)
       || (state & (SOLO1 | SOLO2)))
     combine_b = false;
@@ -438,4 +442,4 @@ Part_combine_music_iterator::get_music (Moment m)const
   return s;
 }
 
-IMPLEMENT_CTOR_CALLBACK(Part_combine_music_iterator);
+IMPLEMENT_CTOR_CALLBACK (Part_combine_music_iterator);