5 #include "inputcommands.hh"
6 #include "inputcommand.hh"
8 #include "staffcommands.hh"
9 #include "getcommand.hh"
13 Commands_at::print() const
16 mtor << "{ at "<<when<<'\n';
17 mtor << "meter " << whole_per_measure
18 << " pos "<< bars << ":" << whole_in_measure <<'\n';
19 for (PCursor<Input_command *> cc(*this); cc.ok(); cc++)
25 Commands_at::Commands_at(Real dt, Commands_at* prev)
29 when = prev->when + dt;
30 whole_per_measure = prev->whole_per_measure;
31 whole_in_measure = prev->whole_in_measure + dt;
34 while ( whole_in_measure >= whole_per_measure ) {
35 whole_in_measure -= whole_per_measure;
38 if (!whole_in_measure) {
39 bottom().add(get_bar_command());
42 whole_per_measure = 1;
50 Commands_at::add(Input_command *i )
53 if (i->args[0] == "METER") { // should check for other meterchanges here.
56 whole_per_measure = l/o;
60 Commands_at::Commands_at(Commands_at const&src)
63 whole_in_measure = whole_in_measure;
64 whole_per_measure = whole_per_measure;
67 IPointerList<Input_command*> &me(*this);
68 const IPointerList<Input_command*> &that(src);
74 Commands_at::setpartial(Real p)
77 error_t ("Partial measure only allowed at beginning.", when);
78 if (p<0||p > whole_per_measure)
79 error_t ("Partial measure has incorrect size", when);
80 whole_in_measure = whole_per_measure - p;
83 Commands_at::barleft()
86 return whole_per_measure-whole_in_measure;
92 Input_cursor::find_moment(Real w)
97 *this = PCursor<Commands_at*>(list().bottom());
98 Real dt = (w - when()) <? ptr()->barleft();
100 Commands_at * c = new Commands_at(dt, *this);
102 } else if (when() == w ) {
104 } else if (when() > w )
113 Real dt = (w - when());
114 Commands_at * c = new Commands_at(dt, *this);
122 Input_commands::Input_commands(Input_commands const&src)
125 IPointerList<Commands_at*> &me(*this);
126 const IPointerList<Commands_at*> &that(src);
131 Input_commands::Input_commands()
134 Commands_at * p = new Commands_at(0,0);
140 Input_commands::do_skip(int bars, Real wholes)
143 Real b = ptr->barleft();
144 ptr.find_moment(ptr->when + b);
148 ptr.find_moment(ptr->when + wholes);
154 Input_commands::add(Input_command c)
156 if (c.args[0] == "PARTIAL") {
157 ptr->setpartial(c.args[1]);
158 } else if (c.args[0] == "METER") {
159 int beats_per_meas = c.args[1];
160 int one_beat = c.args[2];
161 Input_command *ch = get_meterchange_command(beats_per_meas, one_beat);
163 } else if (c.args[0] == "KEY" || c.args[0] == "CLEF") {
164 Input_command *ic = new Input_command(c);
166 } else if (c.args[0] == "SKIP") {
167 int bars = c.args[1] ;
168 Real wholes= c.args[2];
169 do_skip(bars, wholes);
170 } else if (c.args[0] == "RESET") {
177 Input_commands::parse() const
180 Staff_commands*nc = new Staff_commands;
182 { /* all pieces should start with a breakable. */
190 for (PCursor<Commands_at*> i(*this); i.ok(); i++)
191 for (PCursor<Input_command *> cc(**i); cc.ok(); cc++) {
192 if (cc->args.sz() && cc->args[0] !="") {
204 Input_commands::print() const
207 for (PCursor<Commands_at*> cc(*this); cc.ok() ; cc++) {
215 Input_cursor::when()const
217 return (*this)->when;
219 Input_cursor::Input_cursor(PCursor<Commands_at *>c)
220 : PCursor<Commands_at*>(c)