]> git.donarmstrong.com Git - lilypond.git/blob - lily/voice-elt.cc
partial: 0.0.46.jcn1.hanjan
[lilypond.git] / lily / voice-elt.cc
1 /*
2   voice-elt.cc -- implement Voice_element
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
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"
16
17
18 void
19 Voice_element::transpose(Melodic_req const&d)const
20 {
21     for (iter_top(reqs,i); i.ok(); i++) {
22         i->transpose(d);
23       }
24 }
25
26 void
27 Voice_element::print() const
28 {
29 #ifndef NPRINT
30     mtor << "voice_element { dur :"<< duration_ <<"\n";
31     for (iter_top(reqs,rc); rc.ok(); rc++) {
32         rc->print();
33     }
34     mtor << "}\n";
35 #endif
36 }
37
38 void
39 Voice_element::add(Request*r)
40 {
41     if (r->duration()) {
42         assert (!duration_  || duration_ == r->duration());
43         duration_ = r->duration();
44     }
45     
46     r->elt_l_ = this;
47     reqs.bottom().add(r);
48 }
49
50
51 Voice_element::Voice_element()
52 {
53     voice_l_ = 0;
54     duration_ = 0;
55     defined_ch_C_ = 0;
56 }
57
58 Voice_element::Voice_element(Voice_element const&src)
59 {
60     defined_ch_C_ = src.defined_ch_C_;
61
62     voice_l_=0;
63     for (iter_top(src.reqs, i); i.ok(); i++)
64         add(i->clone());
65
66 }
67 bool
68 Voice_element::find_plet_start_b(char c, Moment& moment_r)
69 {
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;
75     }
76     return false;
77 }
78
79 void
80 Voice_element::set_default_group(String s)
81 {
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);
88 }
89
90 void
91 Voice_element::set_plet_backwards(Moment& now_moment_r,
92                                   Moment until_moment, int num_i, int den_i)
93 {
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;
103             
104         }
105     }
106 }