lilypond-0.1.37
[lilypond.git] / src / voice.cc
blob6301f299451916d676a84c934e8ecf4d74dda6c3
1 /*
2 voice.cc -- implement Voice
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
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"
17 void
18 Voice::set_default_group(String s)
20 elts.top()->set_default_group(s);
23 bool
24 Voice::find_plet_start_bo(char c, Moment& moment_r)
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;
32 void
33 Voice::set_plet_backwards(Moment& now_moment_r, Moment until_moment,
34 int num_i, int den_i)
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;
43 Voice::Voice(Voice const&src)
45 for (iter_top(src.elts, i); i.ok(); i++)
46 add(new Voice_element(**i));
48 start = src.start;
51 Voice::Voice()
53 start = 0;
56 void
57 Voice::add(Voice_element*v)
59 v->voice_l_ = this;
60 elts.bottom().add(v);
63 void
64 Voice::print() const
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
74 Moment
75 Voice::last() const
77 Moment l =0;
78 if (elts.size())
79 l = start;
81 for (iter_top(elts,i); i.ok(); i++)
82 l += i->duration;
83 return l;