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