lilypond-1.3.28
[lilypond.git] / lily / voice.cc
blobf248f3aa0e5bf931dcd722530e03806f75396971
1 /*
2 voice.cc -- implement Voice
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
9 #include "proto.hh"
10 #include "plist.hh"
11 #include "debug.hh"
12 #include "voice.hh"
13 #include "musical-request.hh"
14 #include "command-request.hh"
15 #include "midi-item.hh"
16 #include "midi-stream.hh"
17 #include "voice-element.hh"
19 void
20 Voice::transpose(Melodic_req const & d)const
22 for (iter_bot(elts_, i); i.ok(); i--)
23 i->transpose(d);
26 void
27 Voice::set_default_group(String s)
29 elts_.top()->set_default_group(s);
32 Voice::Voice(Voice const&src)
34 for (iter_top(src.elts_, i); i.ok(); i++)
35 add(new Voice_element(**i));
37 start_ = src.start_;
40 Voice::Voice()
42 start_ = 0;
45 void
46 Voice::add(Voice_element*v)
48 v->voice_C_ = this;
49 elts_.bottom().add(v);
52 void
53 Voice::print() const
55 #ifndef NPRINT
56 mtor << "Voice { start_: "<< start_<<eol;
57 for (iter_top(elts_,i); i.ok(); i++)
58 i->print();
59 mtor << "}\n";
60 #endif
63 /**
64 @return The moment at which last element stops.
66 Moment
67 Voice::last() const
69 Moment l =0;
70 if (elts_.size())
71 l = start_;
73 for (iter_top(elts_,i); i.ok(); i++)
74 l += i->duration_;
75 return l;