2 pulk-voices.cc -- implement Pulk_voices
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
9 #include "pulk-voice.hh"
10 #include "pulk-voices.hh"
13 #include "request-column.hh"
16 Pulk_voices::Pulk_voices(Link_list<Staff*> const& l)
21 Moment min_staff_last_mom=1e8; // ugh
22 for (iter_top(l, i); i.ok(); i++, staff_i++) {
24 for (iter_top(i->voice_list_,j); j.ok(); j++) {
25 if (j->elts_.size()) {
26 staff_last = staff_last >? j->last();
27 voice_pq_.insert(Voice_l(j, staff_i));
30 min_staff_last_mom = min_staff_last_mom <? staff_last;
31 last_ = last_ >? staff_last;
33 next_mom_ = voice_pq_.front().l_->start_;
36 if (last_ != min_staff_last_mom)
37 warning("Not all staffs end simultaneously");
41 Pulk_voices::get_aligned_request(Request_column* col_l)
43 while (voice_pq_.size() && voice_pq_.front().l_->start_ == next_mom_) {
44 Voice_l v = voice_pq_.get();
45 pulk_p_list_.bottom().add( new Pulk_voice ( v.l_, v.staff_idx_ ));
48 /* hairy. #i# is a cursor which points to Pulk_voice (which a
49 cursor, essentially) */
51 Moment new_next_mom = last_;
52 iter(pulk_p_list_.top() , i);
54 mtor << "considering staff"<< i->staff_idx_ << "at " << i->when() << "\n";
55 assert (i->when() >= next_mom_);
56 if (i->when() == next_mom_) {
57 col_l->add_reqs(i->staff_idx_, i->get_req_l_arr() );
64 new_next_mom = new_next_mom <? i->when();
68 if (voice_pq_.size() )
69 new_next_mom = new_next_mom <? voice_pq_.front().l_->start_;
70 next_mom_ = new_next_mom;
75 Pulk_voices::ok() const
77 return pulk_p_list_.size() || voice_pq_.size();
80 int compare(Voice_l const& v1, Voice_l const& v2)
82 return sign(v1.l_->start_ - v2.l_->start_);