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