]> git.donarmstrong.com Git - lilypond.git/blob - voice.cc
release: 0.0.6
[lilypond.git] / voice.cc
1 #include "debug.hh"
2 #include "voice.hh"
3
4 void
5 Voice_element::add(Request*r)
6 {
7     if (r->rhythmic()) {
8         assert (!duration);         
9         duration = r->duration();
10     }
11     reqs.bottom().add(r);
12 }
13
14 Voice::Voice()
15 {
16     start = 0.0;
17 }
18
19 void
20 Voice::add(Voice_element*v)
21 {
22     elts.bottom().add(v);
23 }
24
25 Voice_element::Voice_element()
26 {
27     voice = 0;
28     group = 0;
29     duration = 0.0;
30 }
31
32 void
33 Voice::print() const
34 {
35         #ifndef NPRINT
36
37     mtor << "start: "<< start<<eol;
38     for (PCursor<Voice_element*> vec(elts); vec.ok(); vec++)
39         vec->print();
40 #endif
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
54 Real
55 Voice::last() const
56 {
57     Real l =start;
58     for (PCursor<Voice_element*> vec(elts); vec.ok(); vec++)
59         l  += vec->duration;
60     return l;
61 }