lilypond-1.3.31
[lilypond.git] / lily / voice-element.cc
blobf08aa773ef1b80e0c3b79b7ba33b6fd575cb087a
1 /*
2 voice-elt.cc -- implement Voice_element
4 source file of the GNU LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
7 */
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"
18 void
19 Voice_element::transpose(Melodic_req const&d)const
21 for (iter_top(req_p_list_,i); i.ok(); i++) {
22 i->transpose(d);
26 void
27 Voice_element::print() const
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();
36 mtor << "}\n";
37 #endif
40 void
41 Voice_element::add(Request*r)
43 if (! principal_req_l_ )
44 principal_req_l_ = r;
46 if (r->duration()) {
47 assert (!duration_ || duration_ == r->duration());
48 duration_ = r->duration();
51 r->elt_l_ = this;
52 req_p_list_.bottom().add(r);
56 Voice_element::Voice_element()
58 principal_req_l_ = 0;
59 voice_C_ = 0;
60 duration_ = 0;
63 Voice_element::Voice_element(Voice_element const&src)
64 : Input(src)
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());
73 void
74 Voice_element::set_default_group(String s)
76 for (iter_top(req_p_list_, i); i.ok(); i++)
77 if (i->command() &&i->command()->groupchange())
78 return ;
79 Group_change_req *greq = new Group_change_req;
80 greq->newgroup_str_ = s;
81 add(greq);