]> git.donarmstrong.com Git - lilypond.git/blob - lily/pulk-voice.cc
31e931a9f384c22641b867366fa302d3b3f2437d
[lilypond.git] / lily / pulk-voice.cc
1 /*
2   pulk-voices.cc -- implement Pulk_voice
3
4   source file of the LilyPond music typesetter
5
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"
12
13 Pulk_voice::Pulk_voice(Voice*voice_l, int idx)
14     :    cur_(voice_l->elts_)
15 {
16     elt_mom_ = voice_l->start_;
17     staff_idx_= idx;
18     set_subtle();
19 }
20
21 Array<Request*>
22 Pulk_voice::get_req_l_arr() return req_l_arr;
23 {
24     Moment w = when();
25     do {
26         Moment sub = subtle_moment_priorities_[subtle_idx_];
27         for (PCursor<Request*> i(cur_->req_p_list_); i.ok(); i++) {
28             Musical_req* m_l = i->musical();
29             if (!sub) {
30                 if (!(m_l && m_l->subtle() && m_l->subtle()->subtime_ )) 
31                     req_l_arr.push(i);
32             } else {
33                 if (m_l && m_l->subtle() && m_l->subtle()->subtime_ == sub)
34                     req_l_arr.push(i);
35             }
36         }
37         next();
38     } while ( ok() && when () == w);
39 }
40
41 void
42 Pulk_voice::set_subtle()
43 {
44     subtle_idx_ =0;
45
46     subtle_moment_priorities_.set_size(0);
47     if (!cur_.ok())
48         return;
49     for (PCursor<Request*> i(cur_->req_p_list_); i.ok(); i++) {
50         Musical_req* m_l = i->musical();
51         if (m_l&&m_l->subtle()){
52             Moment sub = m_l->subtle()->subtime_;
53             subtle_moment_priorities_.insert(sub);
54         } else {
55             subtle_moment_priorities_.insert(0);
56         }
57     }
58 }
59
60 void
61 Pulk_voice::next()
62 {
63     assert(ok());
64     subtle_idx_++;
65     if (subtle_idx_ == subtle_moment_priorities_.size()) {
66         elt_mom_ += cur_->duration_;
67         cur_ ++;
68         set_subtle();
69     }
70 }
71
72 Moment
73 Pulk_voice::when()const
74 {
75     return elt_mom_ + subtle_moment_priorities_[subtle_idx_];
76 }