struct Command {
Commandcode code;
- Real when;
+// Real when;
/// analogous to argv[]
svec<Scalar> args;
/****************/
Command();
- Command(Real w);
+// Command(Real w);
bool isbreak()const;
void print() const;
};
#include "proto.hh"
-Command* get_meter_command( Real,int,int);
+Command* get_meter_command(int,int);
#include "vray.hh"
#include "plist.hh"
+
+struct Staff_commands_at : public IPointerList<Command*> {
+ Real when;
+
+ /****************/
+
+ bool is_breakable();
+
+ Staff_commands_at(Real);
+ void set_breakable();
+ void add_command_to_break(Command pre, Command mid,Command post);
+ void print() const;
+ void OK() const;
+ void insert_between(Command victim, PCursor<Command*> firstc,
+ PCursor<Command*> last);
+ void add(Command c);
+
+};
+
/// the list of commands in Score
-struct Staff_commands : public IPointerList<Command*> {
- void process_add(Command);
- void add_seq(svec<Command>,bool);
+struct Staff_commands : public IPointerList<Staff_commands_at*>
+{
+ Staff_commands_at*find(Real);
+ void add(Command,Real);
void clean(Real last);
- void set_breakable(Real when);
- bool is_breakable(Real w);
- PCursor<Command*> last_insertion(Real w);
- PCursor<Command*> first(Real w);
- void add_command_to_break(Command pre, Command mid,Command post);
void OK() const;
void print() const;
Real last() const;
- void insert_between(Command victim, PCursor<Command*> firstc,
- PCursor<Command*> last);
};
/** the list of commands in Score. Put in a separate class, since it
otherwise clutters the methods of Score.
- This class serves two purposes: it stores the commands (via
- parser_add()) in the yacc parser. at a later stage, some 'high
- level' commands are converted (method: parse())
*/
#endif
}
Command *
-get_meter_command(Real w, int n, int m)
+get_meter_command(int n, int m)
{
Command*c = new Command;
- c->when = w;
+// c->when = w;
c->code = TYPESET;
c->args.add( "METER");
c->args.add( n );
Commands_at::print() const
{
#ifndef NPRINT
- mtor << "{ at "<<when<<'\n';
+ mtor << "Commands_at { at "<<when<<'\n';
mtor << "meter " << whole_per_measure
<< " pos "<< bars << ":" << whole_in_measure <<'\n';
for (PCursor<Input_command *> cc(*this); cc.ok(); cc++)
}
void
-Commands_at::add(Input_command *i )
+Commands_at::add(Input_command *i)
{
bottom().add(i);
if (i->args[0] == "METER") { // should check for other meterchanges here.
}
Real
Commands_at::barleft()
-
{
return whole_per_measure-whole_in_measure;
}
Staff_commands*nc = new Staff_commands;
{ /* all pieces should start with a breakable. */
- Command c(0.0);
+ Command c;//(0.0);
c.code = INTERPRET;
c.args.add("BAR");
c.args.add("empty");
- nc->process_add(c);
+ nc->add(c,0.0);
}
for (PCursor<Commands_at*> i(*this); i.ok(); i++)
for (PCursor<Input_command *> cc(**i); cc.ok(); cc++) {
if (cc->args.sz() && cc->args[0] !="") {
Command c = **cc;
- c.when = i->when;
- nc->process_add(c);
+// c.when = i->when;
+ nc->add(c, i->when);
}
}
c_position = c;
}
-
void
Keyitem::read(svec<int> s)
{
}
void
-Keyitem::preprocess() {
+Keyitem::preprocess()
+{
brew_molecole();
}
#include "slur.hh"
#include "localkeyitem.hh"
+Rhythmic_grouping
+parse_grouping(svec<Scalar> a)
+{
+ Rhythmic_grouping ret;
+ Real one_beat =a[0];
+ a.del(0);
+ svec<int> r;
+ for (int i= 0 ; i < a.sz(); i++)
+ r.add(a[i]);
+ Real here =0.0;
+ for (int i=0; i < r.sz(); i++) {
+ ret.divisions.add(here);
+ Real last = here;
+ here += one_beat * r[i];
+ Rhythmic_grouping *child =new Rhythmic_grouping(Interval(last, here));
+ child->split(r[i]);
+ ret.children.add(child);
+ }
+ ret.divisions.add(here);
+}
+
void
Simple_walker::do_INTERPRET_command(Command*com)
{
- if (com->args[0] == "BAR") {
+ svec<Scalar> args(com->args);
+ args.del(0);
+ if (com->args[0] == "GROUPING") {
+ default_grouping = parse_grouping(args);
+ }else if (com->args[0] == "BAR") {
local_key_.reset(key_);
+ current_grouping = default_grouping;
} else if (com->args[0] == "KEY") {
- svec<Scalar>s(com->args);
- s.del(0);
- if (com->when) {
+
+ if (col()->when()) {
assert(!oldkey_undo);
- oldkey_undo = new svec<int>( key_.oldkey_undo(s));
+ oldkey_undo = new svec<int>( key_.oldkey_undo(args));
}
- typesetkey = key_.read(s);
+ typesetkey = key_.read(args);
local_key_.reset(key_);
} else if (com->args[0] == "CLEF") {
- svec<Scalar>s(com->args);
- s.del(0);
- clef_.read(s);
+ clef_.read(args);
} else {
WARN << " ignoring INTERPRET command: " << com->args[0]<< '\n';
}
}
}
- for (PCursor<Command*> cc(*staff_commands_); cc.ok(); cc++) {
+ for (PCursor<Staff_commands_at*> cc(*staff_commands_); cc.ok(); cc++) {
Staff_column *sc=get_col(cc->when,false);
- sc->s_commands.add(cc);
+ for (PCursor<Command*> i(**cc); i.ok(); i++)
+ sc->s_commands.add(i);
}
}