lilypond-1.3.130
[lilypond.git] / lily / voice-elt.cc
blob4e334378864b6768ba164cb7f8ffa5d916cdc5ad
1 /*
2 voice-elt.cc -- implement Voice_element
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "proto.hh"
10 #include "plist.hh"
11 #include "debug.hh"
12 #include "voice.hh"
13 #include "voice-element.hh"
14 #include "musical-request.hh"
15 #include "command-request.hh"
18 void
19 Voice_element::transpose(Melodic_req const&d)const
21 for (iter_top(reqs,i); i.ok(); i++) {
22 i->transpose(d);
26 void
27 Voice_element::print() const
29 #ifndef NPRINT
30 mtor << "voice_element { dur :"<< duration_ <<"\n";
31 for (iter_top(reqs,rc); rc.ok(); rc++) {
32 rc->print();
34 mtor << "}\n";
35 #endif
38 void
39 Voice_element::add(Request*r)
41 if (r->duration()) {
42 assert (!duration_ || duration_ == r->duration());
43 duration_ = r->duration();
46 r->elt_l_ = this;
47 reqs.bottom().add(r);
51 Voice_element::Voice_element()
53 voice_l_ = 0;
54 duration_ = 0;
55 defined_ch_C_ = 0;
58 Voice_element::Voice_element(Voice_element const&src)
60 defined_ch_C_ = src.defined_ch_C_;
62 voice_l_=0;
63 for (iter_top(src.reqs, i); i.ok(); i++)
64 add(i->clone());
67 bool
68 Voice_element::find_plet_start_b(char c, Moment& moment_r)
70 assert( c == ']' );
71 moment_r += duration_;
72 for ( PCursor<Request*> i( reqs.top() ); i.ok(); i++ ) {
73 if (i->beam() && i->beam()->spantype == Span_req::START )
74 return true;
76 return false;
79 void
80 Voice_element::set_default_group(String s)
82 for (iter_top(reqs, i); i.ok(); i++)
83 if (i->groupchange())
84 return ;
85 Group_change_req *greq = new Group_change_req;
86 greq->newgroup_str_ = s;
87 add(greq);
90 void
91 Voice_element::set_plet_backwards(Moment& now_moment_r,
92 Moment until_moment, int num_i, int den_i)
94 now_moment_r += duration_;
95 if ( now_moment_r > until_moment )
96 return;
97 for ( PCursor<Request*> i( reqs.top() ); i.ok(); i++ ) {
98 if (i->beam() && i->beam()->spantype == Span_req::START )
99 i->beam()->nplet = den_i;
100 if (i->rhythmic()) {
101 i->rhythmic()->duration_.plet_.type_i_ = den_i;
102 i->rhythmic()->duration_.plet_.iso_i_ = num_i;