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