X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftuplet-iterator.cc;h=c43e630c4384e51f4c0acf44a158918fb5467df8;hb=8659a99f233f5c4684292728e7ad4206669b35b0;hp=97737db0f2b8582f19f24c6213119886d20a57b6;hpb=1c846b2c2348b4e0ca4a3c2e8fb267047ba2d203;p=lilypond.git diff --git a/lily/tuplet-iterator.cc b/lily/tuplet-iterator.cc index 97737db0f2..c43e630c43 100644 --- a/lily/tuplet-iterator.cc +++ b/lily/tuplet-iterator.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 1998--2011 Han-Wen Nienhuys , + Copyright (C) 1998--2015 Han-Wen Nienhuys , Erik Sandberg 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,21 +63,20 @@ 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 (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 ()); - } + ev->set_property ("length", spanner_duration_.smobbed_copy ()); + } synthesized_events_ = scm_cons (ev_scm, synthesized_events_); return ev; @@ -104,34 +104,37 @@ Tuplet_iterator::process (Moment m) && m.main_part_ == next_split_mom_) { descend_to_bottom_context (); - if (tuplet_handler_.get_outlet ()) - create_event (STOP)->send_to_context (tuplet_handler_.get_outlet ()); + if (tuplet_handler_.get_context ()) + create_event (STOP)->send_to_context (tuplet_handler_.get_context ()); if (m.main_part_ < music_get_length ().main_part_) - { - tuplet_handler_.set_context (get_outlet ()); - report_event (create_event (START)); - - next_split_mom_ += spanner_duration_; - } + { + spanner_duration_ = + min (music_get_length () - next_split_mom_, spanner_duration_); + tuplet_handler_.set_context (get_outlet ()); + report_event (create_event (START)); + + next_split_mom_ += spanner_duration_; + } else - tuplet_handler_.set_context (0); + tuplet_handler_.set_context (0); } Music_wrapper_iterator::process (m); if (child_iter_ && child_iter_->ok ()) descend_to_child (child_iter_->get_outlet ()); - + } void Tuplet_iterator::construct_children () { - spanner_duration_ = music_get_length (); - - Moment *mp - = unsmob_moment (get_outlet ()->get_property ("tupletSpannerDuration")); - if (mp) - spanner_duration_ = min (mp->main_part_, spanner_duration_); + if (Duration *d = unsmob (get_music ()->get_property ("duration"))) + spanner_duration_ = d->get_length (); + else if (Moment *mp + = unsmob (get_outlet ()->get_property ("tupletSpannerDuration"))) + spanner_duration_ = mp->main_part_; + else + spanner_duration_.set_infinite (1); Music_wrapper_iterator::construct_children ();