]> git.donarmstrong.com Git - lilypond.git/blob - src/voice.cc
release: 0.0.26
[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_l_ = 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  || duration == r->duration());           
63         duration = r->duration();
64     }
65     
66     r->elt_l_ = this;
67     reqs.bottom().add(r);
68 }
69
70
71 Voice_element::Voice_element()
72 {
73     voice_l_ = 0;
74 //    group = 0;
75     duration = 0.0;
76 }
77
78 Voice_element::Voice_element(Voice_element const&src)
79 {
80     voice_l_=0;
81     for (iter_top(src.reqs, i); i.ok(); i++)
82         add(i->clone());
83 //    group=src.group;
84 }