lilypond-1.3.21
[lilypond.git] / src / voiceelt.cc
blob501ffbc89b500d08da5ea8df04250e8a3a632938
1 /*
2 voiceelt.cc -- implement Voice_element
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "debug.hh"
10 #include "voice.hh"
11 #include "voice-element.hh"
12 #include "musicalrequest.hh"
13 #include "commandrequest.hh"
16 void
17 Voice_element::print() const
19 #ifndef NPRINT
20 mtor << "voice_element { dur :"<< duration <<"\n";
21 for (iter_top(reqs,rc); rc.ok(); rc++) {
22 rc->print();
24 mtor << "}\n";
25 #endif
28 void
29 Voice_element::add(Request*r)
31 if (r->duration()) {
32 assert (!duration || duration == r->duration());
33 duration = r->duration();
36 r->elt_l_ = this;
37 reqs.bottom().add(r);
41 Voice_element::Voice_element()
43 voice_l_ = 0;
44 duration = 0;
45 defined_ch_c_l_ = 0;
48 Voice_element::Voice_element(Voice_element const&src)
50 defined_ch_c_l_ = src.defined_ch_c_l_;
52 voice_l_=0;
53 for (iter_top(src.reqs, i); i.ok(); i++)
54 add(i->clone());
57 bool
58 Voice_element::find_plet_start_bo(char c, Moment& moment_r)
60 assert( c == ']' );
61 moment_r += duration;
62 for ( PCursor<Request*> req_l_pcur( reqs.top() ); req_l_pcur.ok(); req_l_pcur++ ) {
63 if (req_l_pcur->beam() && req_l_pcur->beam()->spantype == Span_req::START )
64 return true;
66 return false;
69 void
70 Voice_element::set_default_group(String s)
72 for (iter_top(reqs, i); i.ok(); i++)
73 if (i->groupchange())
74 return ;
75 Group_change_req *greq = new Group_change_req;
76 greq->newgroup_str_ = s;
77 add(greq);
80 void
81 Voice_element::set_plet_backwards(Moment& now_moment_r,
82 Moment until_moment, int num_i, int den_i)
84 now_moment_r += duration;
85 if ( now_moment_r > until_moment )
86 return;
87 for ( PCursor<Request*> req_l_pcur( reqs.top() ); req_l_pcur.ok(); req_l_pcur++ ) {
88 if (req_l_pcur->beam() && req_l_pcur->beam()->spantype == Span_req::START )
89 req_l_pcur->beam()->nplet = den_i;
90 if (req_l_pcur->rhythmic())
91 req_l_pcur->rhythmic()->plet_factor = Moment(num_i, den_i);
92 if (req_l_pcur->stem())
93 req_l_pcur->stem()->plet_factor = Moment(num_i, den_i);