- now_heads_.sort (CHead_melodic_tuple::pitch_compare);
- stopped_heads_.sort (CHead_melodic_tuple::pitch_compare);
-
- SCM head_list = SCM_EOL;
-
- int j = stopped_heads_.size ()-1;
- int i = now_heads_.size ()-1;
-
- while (i >= 0 && j >=0)
- {
- int comp
- = Pitch::compare (*unsmob_pitch (now_heads_[i].req_l_->get_mus_property ("pitch")),
- *unsmob_pitch (stopped_heads_[j].req_l_->get_mus_property ("pitch")));
-
- if (comp)
- {
- (comp < 0) ? j -- : i--;
- continue;
- }
- else
- {
- head_list = gh_cons (gh_cons (stopped_heads_[j].head_l_->self_scm (),
- now_heads_[i].head_l_->self_scm ()),
- head_list);
-
- past_notes_pq_. insert (now_heads_[i]);
- now_heads_.del (i);
- stopped_heads_.del (j);
- i--;
- j--;
- }
- }
-
- SCM basic = get_property ("Tie");
- SCM sparse = get_property ("sparseTies");
- if (to_boolean (sparse))
- {
- int i = scm_ilength (head_list);
-
- if (!i)
- return;
-
- SCM pair = gh_list_ref (head_list, gh_int2scm (i/2));
-
- Spanner * p = new Spanner (basic);
-
- Tie::set_interface (p);
- Tie::set_head (p,LEFT, dynamic_cast<Item*> (unsmob_grob (gh_car (pair))));
- Tie::set_head (p,RIGHT, dynamic_cast<Item*> (unsmob_grob (gh_cdr (pair))));
-
- tie_p_arr_.push (p);
- announce_grob (p, req_l_);
- }
- else for (SCM s = head_list; gh_pair_p (s); s = gh_cdr (s))
- {
- Grob * p = new Spanner (basic);
- Tie::set_interface (p);
-
- Tie::set_head (p, LEFT, dynamic_cast<Item*> (unsmob_grob (gh_caar (s))));
- Tie::set_head (p, RIGHT, dynamic_cast<Item*> (unsmob_grob (gh_cdar (s))));
-
- tie_p_arr_.push (p);
- announce_grob (p, req_l_);
- }
-
- if (tie_p_arr_.size () > 1 && !tie_column_p_)
- {
- tie_column_p_ = new Spanner (get_property ("TieColumn"));
- Tie_column::set_interface (tie_column_p_);
- for (int i = tie_p_arr_.size (); i--;)
- Tie_column::add_tie (tie_column_p_,tie_p_arr_ [i]);
- announce_grob (tie_column_p_, 0);
- }