+#include "music-wrapper-iterator.hh"
+#include "stream-event.hh"
+
+/*
+ Iterates \times, by sending TupletSpanEvents at the start/end of each
+ tuplet bracket. Extra stop/start events are sent at regular
+ intervals if tupletSpannerDuration is set.
+*/
+class Time_scaled_music_iterator : public Music_wrapper_iterator
+{
+public:
+ DECLARE_SCHEME_CALLBACK (constructor, ());
+ /* construction */
+ DECLARE_CLASSNAME (Time_scaled_music_iterator);
+ Time_scaled_music_iterator ();
+protected:
+ virtual void process (Moment m);
+ virtual void construct_children ();
+ virtual void derived_mark () const;
+ virtual Moment pending_moment () const;
+
+ Music *create_event (Direction d);
+
+private:
+
+ /* tupletSpannerDuration */
+ Moment spanner_duration_;
+
+ /* next time to add a stop/start pair */
+ Moment next_split_mom_;
+
+ /* Recycle start/stop events if tupletSpannerDuration is set. */
+ SCM synthesized_events_;
+
+ Context_handle tuplet_handler_;
+};
+
+Music*
+Time_scaled_music_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));
+
+ Music *mus = get_music ();
+
+ Music *ev = unsmob_music (ev_scm);
+ ev->set_spot (*mus->origin ());
+ if (d == START)
+ {
+ ev->set_property ("numerator", mus->get_property ("numerator"));
+ ev->set_property ("denominator", mus->get_property ("denominator"));
+ ev->set_property ("tweaks", mus->get_property ("tweaks"));
+ ev->set_property ("length", spanner_duration_.smobbed_copy ());
+ }
+
+ synthesized_events_ = scm_cons (ev_scm, synthesized_events_);
+ return ev;
+}
+