+
+ if (Stem::get_beam (stem))
+ {
+ if (stems_)
+ junk_beam ();
+ return;
+ }
+
+ int durlog = unsmob_duration (ev->get_property ("duration"))->duration_log ();
+
+ if (durlog <= 2)
+ {
+ if (stems_)
+ end_beam ();
+ return;
+ }
+
+ /*
+ ignore grace notes.
+ */
+ Moment now = now_mom ();
+ if (bool (beam_start_location_.grace_part_) != bool (now.grace_part_))
+ return;
+
+ Duration *stem_duration = unsmob_duration (ev->get_property ("duration"));
+ Moment dur = stem_duration->get_length ();
+
+ //Moment dur = unsmob_duration (ev->get_property ("duration"))->get_length ();
+ Moment measure_now = measure_position (context ());
+ bool recheck_needed = false;
+
+ if (dur < shortest_mom_)
+ {
+ /* new shortest moment, so store it and set recheck_needed */
+ shortest_mom_ = dur;
+ recheck_needed = true;
+ }
+
+ /* end should be based on shortest_mom_, begin should be
+ based on current duration */
+ consider_end (measure_now, shortest_mom_);
+ consider_begin (measure_now, dur);
+
+ if (!stems_)
+ return;
+
+ grouping_->add_stem (now - beam_start_moment_ + beam_start_location_,
+ durlog - 2,
+ Stem::is_invisible (stem),
+ stem_duration->factor (),
+ (stem->get_property ("tuplet-start") == SCM_BOOL_T));
+ stems_->push_back (stem);
+ last_add_mom_ = now;
+ extend_mom_ = max (extend_mom_, now) + get_event_length (ev, now);
+ if (recheck_needed)
+ recheck_beam ();