]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/tuplet-iterator.cc
Web-ja: update introduction
[lilypond.git] / lily / tuplet-iterator.cc
index ca7533dce903b301d36c1ddd4356b5f165cccbde..c43e630c4384e51f4c0acf44a158918fb5467df8 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1998--2014 Han-Wen Nienhuys <hanwen@xs4all.nl>,
+  Copyright (C) 1998--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>,
                  Erik Sandberg <mandolaerik@gmail.com>
 
   LilyPond is free software: you can redistribute it and/or modify
@@ -24,6 +24,7 @@
 #include "music.hh"
 #include "music-wrapper-iterator.hh"
 #include "stream-event.hh"
+#include "lily-imports.hh"
 
 /*
   Iterates \times, by sending TupletSpanEvents at the start/end of each
@@ -62,13 +63,12 @@ private:
 Music *
 Tuplet_iterator::create_event (Direction d)
 {
-  SCM ev_scm = scm_call_2 (ly_lily_module_constant ("make-span-event"),
-                           ly_symbol2scm ("TupletSpanEvent"),
-                           scm_from_int (d));
+  SCM ev_scm = Lily::make_span_event (ly_symbol2scm ("TupletSpanEvent"),
+                                      scm_from_int (d));
 
   Music *mus = get_music ();
 
-  Music *ev = unsmob_music (ev_scm);
+  Music *ev = unsmob<Music> (ev_scm);
   ev->set_spot (*mus->origin ());
   if (d == START)
     {
@@ -109,6 +109,8 @@ Tuplet_iterator::process (Moment m)
 
       if (m.main_part_ < music_get_length ().main_part_)
         {
+          spanner_duration_ =
+            min (music_get_length () - next_split_mom_, spanner_duration_);
           tuplet_handler_.set_context (get_outlet ());
           report_event (create_event (START));
 
@@ -126,17 +128,13 @@ Tuplet_iterator::process (Moment m)
 void
 Tuplet_iterator::construct_children ()
 {
-  if (Duration *d = unsmob_duration (get_music ()->get_property ("duration")))
+  if (Duration *d = unsmob<Duration> (get_music ()->get_property ("duration")))
     spanner_duration_ = d->get_length ();
+  else if (Moment *mp
+           = unsmob<Moment> (get_outlet ()->get_property ("tupletSpannerDuration")))
+    spanner_duration_ = mp->main_part_;
   else
-    {
-      spanner_duration_ = music_get_length ();
-
-      Moment *mp
-        = unsmob_moment (get_outlet ()->get_property ("tupletSpannerDuration"));
-      if (mp)
-        spanner_duration_ = min (mp->main_part_, spanner_duration_);
-    }
+    spanner_duration_.set_infinite (1);
 
   Music_wrapper_iterator::construct_children ();