]> git.donarmstrong.com Git - lilypond.git/blob - src/voice.cc
release: 0.0.23
[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,i); i.ok(); i++)
31         i->print();
32 #endif
33 }
34
35 Moment
36 Voice::last() const
37 {
38     Moment l =0;
39     if (elts.size())
40         l = start;
41     
42     for (iter_top(elts,i); i.ok(); i++)
43         l  += i->duration;
44     return l;
45 }
46 /****************************************************************/
47 void
48 Voice_element::print() const
49 {
50 #ifndef NPRINT
51     mtor << "voice_element { dur :"<< duration <<"\n";
52     for (iter_top(reqs,rc); rc.ok(); rc++) {
53         rc->print();
54     }
55     mtor << "}\n";
56 #endif
57 }
58 void
59 Voice_element::add(Request*r)
60 {
61     if (r->rhythmic()) {
62         assert (!duration);         
63         duration = r->duration();
64     }
65     r->elt_l_ = this;
66     reqs.bottom().add(r);
67 }
68
69
70 Voice_element::Voice_element()
71 {
72     voice_ = 0;
73     group = 0;
74     duration = 0.0;
75 }
76
77 Voice_element::Voice_element(Voice_element const&src)
78 {
79     voice_=src.voice_;
80     for (iter_top(src.reqs, i); i.ok(); i++)
81         add(i->clone());
82     group=src.group;
83 }