]> git.donarmstrong.com Git - lilypond.git/blob - src/voice.cc
release: 0.0.22
[lilypond.git] / src / voice.cc
1 #include "debug.hh"
2 #include "voice.hh"
3 #include "request.hh"
4
5 Voice::Voice(Voice const&src)
6 {
7     for (iter_top(src.elts, i); i.ok(); i++)
8         add(new Voice_element(**i));
9
10     start = src.start;
11 }
12
13 Voice::Voice()
14 {
15     start = 0.0;
16 }
17
18 void
19 Voice::add(Voice_element*v)
20 {
21     v->voice_ = this;
22     elts.bottom().add(v);
23 }
24
25 void
26 Voice::print() const
27 {
28 #ifndef NPRINT
29     mtor << "start: "<< start<<eol;
30     for (iter_top(elts,vec); vec.ok(); vec++)
31         vec->print();
32 #endif
33 }
34
35 Moment
36 Voice::last() const
37 {
38     Moment l =start;
39     for (iter_top(elts,vec); vec.ok(); vec++)
40         l  += vec->duration;
41     return l;
42 }
43 /****************************************************************/
44 void
45 Voice_element::print() const
46 {
47 #ifndef NPRINT
48     mtor << "voice_element { dur :"<< duration <<"\n";
49     for (iter_top(reqs,rc); rc.ok(); rc++) {
50         rc->print();
51     }
52     mtor << "}\n";
53 #endif
54 }
55 void
56 Voice_element::add(Request*r)
57 {
58     if (r->rhythmic()) {
59         assert (!duration);         
60         duration = r->duration();
61     }
62     r->elt_l_ = this;
63     reqs.bottom().add(r);
64 }
65
66
67 Voice_element::Voice_element()
68 {
69     voice_ = 0;
70     group = 0;
71     duration = 0.0;
72 }
73
74 Voice_element::Voice_element(Voice_element const&src)
75 {
76     voice_=src.voice_;
77     for (iter_top(src.reqs, i); i.ok(); i++)
78         add(i->clone());
79     group=src.group;
80 }