- for (int i = 0; i < volta_p_arr_.size (); i++)
- if (volta_p_arr_[i] && (now >= alternative_start_mom_arr_[i]))
- volta_p_arr_[i]->add_column (c);
+ int last_number = 0;
+ int volta_number = repeated_music_l_->repeats_i_ - alt->length_i () + 1;
+
+ /*
+ all repeat alternatives, and generate events with
+ appropriate timestamps. The volta spanner event (a number string)
+ happens at the begin of the alt. The :| bar event at the ending.
+ */
+ for (Cons<Music> *i = alt->music_p_list_p_->head_; i; i = i->next_)
+ {
+
+ /*
+ some idiot might typeset a repeat not starting on a
+ barline. Make sure there is one.
+
+ (todo: should try to avoid line breaks?)
+ */
+ if (last_number == 0)
+ {
+ becel.append (new Bar_create_event (walk_mom, ""));
+ }
+
+
+ if (create_volta)
+ {
+ Bar_create_event * c = new Bar_create_event (walk_mom, last_number+ 1,
+ volta_number);
+
+ if (!i->next_)
+ c->last_b_ = true;
+
+ becel.append (c);
+ last_number = volta_number;
+ volta_number ++;
+ SCM l (get_property ("voltaSpannerDuration"));
+ if (SMOB_IS_TYPE_B (Moment, l))
+ {
+ Moment vSD_mom = *SMOB_TO_TYPE (Moment,l);
+ if ( vSD_mom < i->car_->length_mom() ) // terminate volta early ?
+ {
+ vSD_mom += walk_mom;
+ c->last_b_ = true;
+ becel.append (new Bar_create_event (vSD_mom, "stop"));
+ }
+ }
+ }
+ walk_mom += i->car_->length_mom();
+
+ if (i->next_)
+ becel.append (new Bar_create_event (walk_mom, ":|"));
+ else
+ becel.append (new Bar_create_event (walk_mom, "stop"));
+ }