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