lilypond-1.3.12
[lilypond.git] / lily / pulk-voice.cc
blobe54c429f422c8568d33c342b44b3d918e93e447d
1 /*
2 pulk-voices.cc -- implement Pulk_voice
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8 #include "pulk-voice.hh"
9 #include "voice.hh"
10 #include "musical-request.hh"
11 #include "voice-element.hh"
13 Pulk_voice::Pulk_voice(Voice*voice_l, int idx)
14 : cur_(voice_l->elts_)
16 elt_mom_ = voice_l->start_;
17 staff_idx_= idx;
18 set_subtle();
21 Array<Request*>
22 Pulk_voice::get_req_l_arr()
24 Array<Request*> req_l_arr;
25 Moment w = when();
26 do {
27 Moment sub = subtle_moment_priorities_[subtle_idx_];
28 for (PCursor<Request*> i(cur_->req_p_list_); i.ok(); i++) {
29 Musical_req* m_l = i->musical();
30 if (!sub) {
31 if (!(m_l && m_l->subtle() && m_l->subtle()->subtime_ ))
32 req_l_arr.push(i);
33 } else {
34 if (m_l && m_l->subtle() && m_l->subtle()->subtime_ == sub)
35 req_l_arr.push(i);
38 next();
39 } while ( ok() && when () == w);
40 return req_l_arr;
43 void
44 Pulk_voice::set_subtle()
46 subtle_idx_ =0;
48 subtle_moment_priorities_.set_size(0);
49 if (!cur_.ok())
50 return;
51 for (PCursor<Request*> i(cur_->req_p_list_); i.ok(); i++) {
52 Musical_req* m_l = i->musical();
53 if (m_l&&m_l->subtle()){
54 Moment sub = m_l->subtle()->subtime_;
55 subtle_moment_priorities_.insert(sub);
56 } else {
57 subtle_moment_priorities_.insert(0);
62 void
63 Pulk_voice::next()
65 assert(ok());
66 subtle_idx_++;
67 if (subtle_idx_ == subtle_moment_priorities_.size()) {
68 elt_mom_ += cur_->duration_;
69 cur_ ++;
70 set_subtle();
74 Moment
75 Pulk_voice::when()const
77 return elt_mom_ + subtle_moment_priorities_[subtle_idx_];