]> git.donarmstrong.com Git - lilypond.git/blob - lily/pulk-voice.cc
release: 0.0.56
[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() 
23 {
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);
36             }
37         }
38         next();
39     } while ( ok() && when () == w);
40     return req_l_arr;
41 }
42
43 void
44 Pulk_voice::set_subtle()
45 {
46     subtle_idx_ =0;
47
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);
58         }
59     }
60 }
61
62 void
63 Pulk_voice::next()
64 {
65     assert(ok());
66     subtle_idx_++;
67     if (subtle_idx_ == subtle_moment_priorities_.size()) {
68         elt_mom_ += cur_->duration_;
69         cur_ ++;
70         set_subtle();
71     }
72 }
73
74 Moment
75 Pulk_voice::when()const
76 {
77     return elt_mom_ + subtle_moment_priorities_[subtle_idx_];
78 }