]> git.donarmstrong.com Git - lilypond.git/blob - src/voice.cc
release: 0.0.30
[lilypond.git] / src / voice.cc
1 #include "debug.hh"
2 #include "voice.hh"
3 #include "request.hh"
4
5 void
6 Voice::set_default_group(String s)
7 {
8     elts.top()->set_default_group(s);
9 }
10
11 Voice::Voice(Voice const&src)
12 {
13     for (iter_top(src.elts, i); i.ok(); i++)
14         add(new Voice_element(**i));
15
16     start = src.start;
17 }
18
19 Voice::Voice()
20 {
21     start = 0.0;
22 }
23
24 void
25 Voice::add(Voice_element*v)
26 {
27     v->voice_l_ = this;
28     elts.bottom().add(v);
29 }
30
31 void
32 Voice::print() const
33 {
34 #ifndef NPRINT
35     mtor << "start: "<< start<<eol;
36     for (iter_top(elts,i); i.ok(); i++)
37         i->print();
38 #endif
39 }
40
41 Moment
42 Voice::last() const
43 {
44     Moment l =0;
45     if (elts.size())
46         l = start;
47     
48     for (iter_top(elts,i); i.ok(); i++)
49         l  += i->duration;
50     return l;
51 }
52 /* *************************************************************** */
53 void
54 Voice_element::print() const
55 {
56 #ifndef NPRINT
57     mtor << "voice_element { dur :"<< duration <<"\n";
58     for (iter_top(reqs,rc); rc.ok(); rc++) {
59         rc->print();
60     }
61     mtor << "}\n";
62 #endif
63 }
64 void
65 Voice_element::add(Request*r)
66 {
67     if (r->rhythmic()) {
68         assert (!duration  || duration == r->duration());           
69         duration = r->duration();
70     }
71     
72     r->elt_l_ = this;
73     reqs.bottom().add(r);
74 }
75
76
77 Voice_element::Voice_element()
78 {
79     voice_l_ = 0;
80     duration = 0;
81     defined_ch_c_l_m = 0;
82 }
83
84 Voice_element::Voice_element(Voice_element const&src)
85 {
86     defined_ch_c_l_m = src.defined_ch_c_l_m;
87                 // are you sure? They can be modified after copying.
88     voice_l_=0;
89     for (iter_top(src.reqs, i); i.ok(); i++)
90         add(i->clone());
91
92 }
93 void
94 Voice_element::set_default_group(String s)
95 {
96     for (iter_top(reqs, i); i.ok(); i++)
97         if (i->groupchange())
98             return ;
99     Group_change_req *greq = new Group_change_req;
100     greq->newgroup_str_ = s;
101     add(greq);
102 }