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