]> git.donarmstrong.com Git - lilypond.git/blob - src/voice.cc
release: 0.0.35
[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 "midiitem.hh"
14 #include "midistream.hh"
15
16 void
17 Voice::set_default_group(String s)
18 {
19     elts.top()->set_default_group(s);
20 }
21
22 bool
23 Voice::find_plet_start_bo(char c, Moment& moment_r)
24 {
25     for (iter_bot(elts, i); i.ok(); i--)
26         if ( i->find_plet_start_bo(c, moment_r) )
27             return true;
28     return false;
29 }
30
31 void 
32 Voice::set_plet_backwards(Moment& now_moment_r, Moment until_moment, int num_i, int den_i)
33 {
34     for (iter_bot(elts, i); i.ok(); i--) 
35         if ( now_moment_r <= until_moment ) 
36             i->set_plet_backwards(now_moment_r, until_moment, num_i, den_i);
37         else
38             return;
39 }
40
41 Voice::Voice(Voice const&src)
42 {
43     for (iter_top(src.elts, i); i.ok(); i++)
44         add(new Voice_element(**i));
45
46     start = src.start;
47 }
48
49 Voice::Voice()
50 {
51     start = 0;
52 }
53
54 void
55 Voice::add(Voice_element*v)
56 {
57     v->voice_l_ = this;
58     elts.bottom().add(v);
59 }
60
61 void
62 Voice::print() const
63 {
64 #ifndef NPRINT
65     mtor << "start: "<< start<<eol;
66     for (iter_top(elts,i); i.ok(); i++)
67         i->print();
68 #endif
69 }
70
71 Moment
72 Voice::last() const
73 {
74     Moment l =0;
75     if (elts.size())
76         l = start;
77     
78     for (iter_top(elts,i); i.ok(); i++)
79         l  += i->duration;
80     return l;
81 }
82