]> git.donarmstrong.com Git - lilypond.git/blob - lily/voice-elt.cc
f244327c5fe6b190ba5c4cd52aeefe156960347c
[lilypond.git] / lily / voice-elt.cc
1 /*
2   voiceelt.cc -- implement Voice_element
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 "voice-element.hh"
14 #include "musical-request.hh"
15 #include "command-request.hh"
16
17
18 void
19 Voice_element::print() const
20 {
21 #ifndef NPRINT
22     mtor << "voice_element { dur :"<< duration <<"\n";
23     for (iter_top(reqs,rc); rc.ok(); rc++) {
24         rc->print();
25     }
26     mtor << "}\n";
27 #endif
28 }
29
30 void
31 Voice_element::add(Request*r)
32 {
33     if (r->duration()) {
34         assert (!duration  || duration == r->duration());
35         duration = r->duration();
36     }
37     
38     r->elt_l_ = this;
39     reqs.bottom().add(r);
40 }
41
42
43 Voice_element::Voice_element()
44 {
45     voice_l_ = 0;
46     duration = 0;
47     defined_ch_c_l_ = 0;
48 }
49
50 Voice_element::Voice_element(Voice_element const&src)
51 {
52     defined_ch_c_l_ = src.defined_ch_c_l_;
53
54     voice_l_=0;
55     for (iter_top(src.reqs, i); i.ok(); i++)
56         add(i->clone());
57
58 }
59 bool
60 Voice_element::find_plet_start_bo(char c, Moment& moment_r)
61 {
62     assert( c == ']' );
63     moment_r += duration;
64     for ( PCursor<Request*> i( reqs.top() ); i.ok(); i++ ) {
65         if (i->beam() && i->beam()->spantype == Span_req::START )
66             return true;
67     }
68     return false;
69 }
70
71 void
72 Voice_element::set_default_group(String s)
73 {
74     for (iter_top(reqs, i); i.ok(); i++)
75         if (i->groupchange())
76             return ;
77     Group_change_req *greq = new Group_change_req;
78     greq->newgroup_str_ = s;
79     add(greq);
80 }
81
82 void
83 Voice_element::set_plet_backwards(Moment& now_moment_r,
84                                   Moment until_moment, int num_i, int den_i)
85 {
86     now_moment_r += duration;
87     if ( now_moment_r > until_moment )
88         return;
89     for ( PCursor<Request*> i( reqs.top() ); i.ok(); i++ ) {
90         if (i->beam() && i->beam()->spantype == Span_req::START )
91             i->beam()->nplet = den_i;
92         if (i->rhythmic())
93             i->rhythmic()->plet_factor = Moment(num_i, den_i);
94         if (i->stem())
95             i->stem()->plet_factor = Moment(num_i, den_i);
96     }
97 }