- 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
- = Musical_pitch::compare (now_heads_[i].req_l_->pitch_ ,
- stopped_heads_[j].req_l_->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 ("basicTieProperties");
- 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));
-
- Tie * p = new Tie (basic);
- p->set_head (LEFT, dynamic_cast<Item*> (unsmob_element (gh_car (pair))));
- p->set_head (RIGHT, dynamic_cast<Item*> (unsmob_element (gh_cdr (pair))));
-
- tie_p_arr_.push (p);
- announce_element (Score_element_info (p, req_l_));
- }
- else for (SCM s = head_list; gh_pair_p (s); s = gh_cdr (s))
- {
- Tie * p = new Tie (basic);
- p->set_head (LEFT, dynamic_cast<Item*> (unsmob_element (gh_caar (s))));
- p->set_head (RIGHT, dynamic_cast<Item*> (unsmob_element (gh_cdar (s))));
-
- tie_p_arr_.push (p);
- announce_element (Score_element_info (p, req_l_));
- }
-
- if (!tie_p_arr_.size ())
- {
- req_l_->warning (_ ("No ties were created!"));
- }
- else if (tie_p_arr_.size () > 1 && !tie_column_p_)
- {
- tie_column_p_ = new Tie_column (get_property ("basicTieColumnProperties"));
- for (int i = tie_p_arr_.size (); i--; )
- tie_column_p_->add_tie (tie_p_arr_ [i]);
- announce_element (Score_element_info (tie_column_p_, 0));
- }