]> git.donarmstrong.com Git - lilypond.git/blob - src/voice.cc
release: 0.0.38
[lilypond.git] / src / voice.cc
1 /*
2   voice.cc -- implement Voice
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
9 #include "debug.hh"
10 #include "voice.hh"
11 #include "musicalrequest.hh"
12 #include "commandrequest.hh"
13 #include "midi-item.hh"
14 #include "midi-stream.hh"
15 #include "voice-element.hh"
16
17 void
18 Voice::set_default_group(String s)
19 {
20     elts.top()->set_default_group(s);
21 }
22
23 bool
24 Voice::find_plet_start_bo(char c, Moment& moment_r)
25 {
26     for (iter_bot(elts, i); i.ok(); i--)
27         if ( i->find_plet_start_bo(c, moment_r) )
28             return true;
29     return false;
30 }
31
32 void 
33 Voice::set_plet_backwards(Moment& now_moment_r, Moment until_moment,
34                           int num_i, int den_i)
35 {
36     for (iter_bot(elts, i); i.ok(); i--) 
37         if ( now_moment_r <= until_moment ) 
38             i->set_plet_backwards(now_moment_r, until_moment, num_i, den_i);
39         else
40             return;
41 }
42
43 Voice::Voice(Voice const&src)
44 {
45     for (iter_top(src.elts, i); i.ok(); i++)
46         add(new Voice_element(**i));
47
48     start = src.start;
49 }
50
51 Voice::Voice()
52 {
53     start = 0;
54 }
55
56 void
57 Voice::add(Voice_element*v)
58 {
59     v->voice_l_ = this;
60     elts.bottom().add(v);
61 }
62
63 void
64 Voice::print() const
65 {
66 #ifndef NPRINT
67     mtor << "Voice { start: "<< start<<eol;
68     for (iter_top(elts,i); i.ok(); i++)
69         i->print();
70     mtor << "}\n";
71 #endif
72 }
73
74 Moment
75 Voice::last() const
76 {
77     Moment l =0;
78     if (elts.size())
79         l = start;
80     
81     for (iter_top(elts,i); i.ok(); i++)
82         l  += i->duration;
83     return l;
84 }
85