]> git.donarmstrong.com Git - lilypond.git/blob - lily/voice.cc
f248f3aa0e5bf931dcd722530e03806f75396971
[lilypond.git] / lily / voice.cc
1 /*
2   voice.cc -- implement Voice
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
8
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"
18
19 void
20 Voice::transpose(Melodic_req const & d)const
21 {
22      for (iter_bot(elts_, i); i.ok(); i--)
23         i->transpose(d); 
24 }
25
26 void
27 Voice::set_default_group(String s)
28 {
29     elts_.top()->set_default_group(s);
30 }
31
32 Voice::Voice(Voice const&src)
33 {
34     for (iter_top(src.elts_, i); i.ok(); i++)
35         add(new Voice_element(**i));
36
37     start_ = src.start_;
38 }
39
40 Voice::Voice()
41 {
42     start_ = 0;
43 }
44
45 void
46 Voice::add(Voice_element*v)
47 {
48     v->voice_C_ = this;
49     elts_.bottom().add(v);
50 }
51
52 void
53 Voice::print() const
54 {
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
61 }
62
63 /**
64    @return The moment at which last element stops.
65  */
66 Moment
67 Voice::last() const
68 {
69     Moment l =0;
70     if (elts_.size())
71         l = start_;
72     
73     for (iter_top(elts_,i); i.ok(); i++)
74         l  += i->duration_;
75     return l;
76 }
77