]> git.donarmstrong.com Git - lilypond.git/blob - lily/voice.cc
release: 0.0.46.jcn1
[lilypond.git] / lily / 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 "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 bool
33 Voice::find_plet_start_b(char c, Moment& moment_r)
34 {
35     for (iter_bot(elts, i); i.ok(); i--)
36         if ( i->find_plet_start_b(c, moment_r) )
37             return true;
38     return false;
39 }
40
41 void 
42 Voice::set_plet_backwards(Moment& now_moment_r, Moment until_moment,
43                           int num_i, int den_i)
44 {
45     for (iter_bot(elts, i); i.ok(); i--) 
46         if ( now_moment_r <= until_moment ) 
47             i->set_plet_backwards(now_moment_r, until_moment, num_i, den_i);
48         else
49             return;
50 }
51
52 Voice::Voice(Voice const&src)
53 {
54     for (iter_top(src.elts, i); i.ok(); i++)
55         add(new Voice_element(**i));
56
57     start = src.start;
58 }
59
60 Voice::Voice()
61 {
62     start = 0;
63 }
64
65 void
66 Voice::add(Voice_element*v)
67 {
68     v->voice_C_ = this;
69     elts.bottom().add(v);
70 }
71
72 void
73 Voice::print() const
74 {
75 #ifndef NPRINT
76     mtor << "Voice { start: "<< start<<eol;
77     for (iter_top(elts,i); i.ok(); i++)
78         i->print();
79     mtor << "}\n";
80 #endif
81 }
82
83 Moment
84 Voice::last() const
85 {
86     Moment l =0;
87     if (elts.size())
88         l = start;
89     
90     for (iter_top(elts,i); i.ok(); i++)
91         l  += i->duration_;
92     return l;
93 }
94