#include "proto.hh"
#include "plist.hh"
#include "real.hh"
-#include "moment.hh"
+#include "timedescription.hh"
struct Commands_at : public IPointerList<Input_command*> {
- Moment moment_;
+ Time_description tdescription_;
/****************/
- Real when();
+ Moment when();
void parse(Staff_commands_at*);
void print() const;
- Real barleft();
+ Moment barleft();
void add(Input_command*);
- void setpartial(Real);
+ void setpartial(Moment);
Commands_at(const Commands_at&);
- Commands_at(Real, Commands_at*prev);
+ Commands_at(Moment, Commands_at*prev);
};
struct Input_cursor : public PCursor<Commands_at*>
{
/****************/
Input_cursor(PCursor<Commands_at*>);
- Real when()const;
- void find_moment(Real w);
+ Moment when()const;
+ void find_moment(Moment w);
void prev() { operator --(0); }
void next() { operator ++(0); }
};
/****************/
- void find_moment(Real);
+ void find_moment(Moment);
void add(Input_command c);
- void do_skip(int bars, Real wholes);
+ void do_skip(int bars, Moment wholes);
Input_commands();
Input_commands(Input_commands const&);
Staff_commands *parse() const;
};
-
-
-void
-interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat,
- Real& whole_per_measure);
#endif // INPUTCOMMANDS_HH
#include "command.hh"
#include "vray.hh"
#include "plist.hh"
-#include "moment.hh"
+#include "timedescription.hh"
struct Staff_commands_at : public IPointerList<Command*> {
- Moment moment_;
+ Time_description tdescription_;
/****************/
bool is_breakable();
- Real when();
- Staff_commands_at(Moment);
+ Moment when();
+ Staff_commands_at(Time_description);
void set_breakable();
void add_command_to_break(Command pre, Command mid,Command post);
void print() const;
/// the list of commands in Score
struct Staff_commands : public IPointerList<Staff_commands_at*>
{
- Staff_commands_at*find(Real);
+ Staff_commands_at*find(Moment);
void add(Staff_commands_at*);
- void clean(Real last);
+ void clean(Moment last);
void OK() const;
void print() const;
- Real last() const;
+ Moment last() const;
};
/** the list of commands in Score. Put in a separate class, since it
otherwise clutters the methods of Score.
#define STCOL_HH
#include "proto.hh"
#include "vray.hh"
+#include "moment.hh"
/// store simultaneous requests
struct Staff_column {
/// idem
Staff_commands_at *s_commands;
- Moment *moment_;
+ Time_description *tdescription_;
/****************/
Staff_column(Score_column*s);
bool mus() const;
- Real when() const;
+ Moment when() const;
void add(Voice_element*ve);
/****************************************************************
{
#ifndef NPRINT
mtor << "Commands_at {";
- moment_.print();
+ tdescription_.print();
for (PCursor<Input_command *> cc(*this); cc.ok(); cc++)
cc->print();
mtor << "}\n";
#endif
}
-Real
+Moment
Commands_at::when()
{
- return moment_.when;
+ return tdescription_.when;
}
-Commands_at::Commands_at(Real dt, Commands_at* prev)
- : moment_(dt, (prev)? &prev->moment_ : 0)
+Commands_at::Commands_at(Moment dt, Commands_at* prev)
+ : tdescription_(dt, (prev)? &prev->tdescription_ : 0)
{
- if (prev&& !moment_.whole_in_measure) {
+ if (prev&& !tdescription_.whole_in_measure) {
bottom().add(get_bar_command());
}
}
if (i->args[0] == "METER") {
int l = i->args[1];
int o = i->args[2];
- moment_.set_meter(l,o);
- bottom().add(get_grouping_command( moment_.one_beat,
- get_default_grouping(l)));
+ tdescription_.set_meter(l,o);
+ bottom().add(get_grouping_command( get_default_grouping(l)));
}
}
Commands_at::Commands_at(Commands_at const&src) :
- moment_(src.moment_)
+ tdescription_(src.tdescription_)
{
IPointerList<Input_command*> &me(*this);
const IPointerList<Input_command*> &that(src);
}
void
-Commands_at::setpartial(Real p)
+Commands_at::setpartial(Moment p)
{
- moment_.setpartial(p);
+ tdescription_.setpartial(p);
}
-Real
+Moment
Commands_at::barleft()
{
- return moment_.barleft();
+ return tdescription_.barleft();
}
void
Commands_at::parse(Staff_commands_at*s)
{
- s->moment_ = moment_;
+ s->tdescription_ = tdescription_;
for (PCursor<Input_command *> cc(*this); cc.ok(); cc++) {
if (cc->args.sz() && cc->args[0] !="") {
Command c = **cc;
/****************/
void
-Input_cursor::find_moment(Real w)
+Input_cursor::find_moment(Moment w)
{
- Real last = when();
+ Moment last = when();
while (1) {
if (! ok() ) {
*this = list().bottom();
- Real dt = (w - when()) <? ptr()->barleft();
+ Moment dt = (w - when()) <? ptr()->barleft();
Commands_at * c = new Commands_at(dt, *this);
assert(c->when() <= w);
}
prev();
- Real dt = (w - when());
+ Moment dt = (w - when());
Commands_at * c = new Commands_at(dt, *this);
add(c);
next();
}
void
-Input_commands::do_skip(int bars, Real wholes)
+Input_commands::do_skip(int bars, Moment wholes)
{
while (bars > 0) {
- Real b = ptr->barleft();
+ Moment b = ptr->barleft();
ptr.find_moment(ptr->when() + b);
bars --;
}
ptr->setpartial(c.args[1]);
} else if (c.args[0] == "GROUPING") {
Input_command *ic = new Input_command(c);
- ic->args.insert(ptr->moment_.one_beat, 1);
+ ic->args.insert(ptr->tdescription_.one_beat, 1);
ptr->add(ic);
} else if (c.args[0] == "METER") {
int beats_per_meas = c.args[1];
ptr->add(ch);
} else if (c.args[0] == "SKIP") {
int bars = c.args[1] ;
- Real wholes= c.args[2];
+ Moment wholes= c.args[2];
do_skip(bars, wholes);
} else if (c.args[0] == "RESET") {
ptr= top();
Staff_commands_at* s= nc->find(i->when());
if (!s){
- s = new Staff_commands_at(i->moment_);
+ s = new Staff_commands_at(i->tdescription_);
nc->add(s);
}
if (!i->when()) { /* all pieces should start with a breakable. */
}
/****************/
-Real
+Moment
Input_cursor::when()const
{
return (*this)->when();
-#include "sccol.hh"
#include "debug.hh"
+#include "pcol.hh"
+#include "sccol.hh"
+
+int
+Score_column::compare(Score_column & c1, Score_column &c2)
+{
+ return sign(c1.when - c2.when);
+}
-Score_column::Score_column(Real w)
+void
+Score_column::set_breakable() {
+ pcol_->set_breakable();
+}
+Score_column::Score_column(Moment w)
{
when = w;
pcol_ = new PCol(0);
}
int
-Real_compare(Real &a , Real& b)
+Tdescription_compare(Moment &a , Moment& b)
{
- return sgn(a-b);
+ return sign(a-b);
}
void
Score_column::preprocess()
{
- durations.sort(Real_compare);
+ durations.sort(Tdescription_compare);
}
void
-Score_column::add_duration(Real d)
+Score_column::add_duration(Moment d)
{
for (int i = 0; i< durations.sz(); i++) {
if (d == durations[i])
}
void
-Staff::process_commands(Real l)
+Staff::process_commands(Moment l)
{
if (staff_commands_)
staff_commands_->clean(l);
}
Staff_column *
-Staff::get_col(Real w, bool mus)
+Staff::get_col(Moment w, bool mus)
{
Score_column* sc = score_->find_col(w,mus);
assert(sc->when == w);
Staff::setup_staffcols()
{
for (PCursor<Voice*> i(voices); i.ok(); i++) {
- Real now = i->start;
+ Moment now = i->start;
for (PCursor<Voice_element *> ve(i->elts); ve.ok(); ve++) {
Staff_column *sc=get_col(now,true);
}
for (PCursor<Staff_commands_at*> cc(*staff_commands_); cc.ok(); cc++) {
- Staff_column *sc=get_col(cc->moment_.when,false);
+ Staff_column *sc=get_col(cc->tdescription_.when,false);
sc->s_commands = cc;
- sc->moment_ = new Moment(cc->moment_);
+ sc->tdescription_ = new Time_description(cc->tdescription_);
}
PCursor<Staff_commands_at*> cc(*staff_commands_);
for (PCursor<Staff_column*> i(cols); i.ok(); i++) {
while ((cc+1).ok() && (cc+1)->when() < i->when())
cc++;
-
- if(!i->moment_) {
- if (cc->moment_.when == i->when())
- i->moment_ = new Moment(cc->moment_);
+
+ if(!i->tdescription_) {
+ if (cc->tdescription_.when == i->when())
+ i->tdescription_ = new Time_description(cc->tdescription_);
else
- i->moment_ = new Moment(
- i->when() - cc->when() ,&cc->moment_);
+ i->tdescription_ = new Time_description(
+ i->when() - cc->when() ,&cc->tdescription_);
}
}
}
}
-Real
+Moment
Staff::last() const
{
- Real l = 0.0;
+ Moment l = 0.0;
for (PCursor<Voice*> i(voices); i.ok(); i++) {
- l = MAX(l, i->last());
+ l = l >? i->last();
}
return l;
}
#include "debug.hh"
#include "parseconstruct.hh"
-Real
+Moment
Staff_commands_at::when()
{
- return moment_.when;
+ return tdescription_.when;
}
void
Staff_commands_at::print() const
#ifndef NPRINT
PCursor<Command*> i (*this);
mtor << "Commands at: " ;
- moment_.print();
+ tdescription_.print();
for (; i.ok(); i++)
i->print();
assert(i->priority >= (i+1)->priority);
}
-Staff_commands_at::Staff_commands_at(Moment m)
- :moment_(m)
+Staff_commands_at::Staff_commands_at(Time_description m)
+ :tdescription_(m)
{
}
insert_between(post, f, l);
}
-
+
+
+/*
+ should move this stuff into inputlanguage.
+ */
void
Staff_commands_at::add(Command c)
{
{
#ifndef NDEBUG
for (PCursor<Staff_commands_at*> i(*this); i.ok() && (i+1).ok(); i++) {
- assert(i->moment_.when <= (i+1)->moment_.when);
+ assert(i->tdescription_.when <= (i+1)->tdescription_.when);
i->OK();
}
#endif
}
Staff_commands_at*
-Staff_commands::find(Real w)
+Staff_commands::find(Moment w)
{
PCursor<Staff_commands_at*> i(bottom());
for (; i.ok() ; i--) {
- if (i->moment_.when == w)
+ if (i->tdescription_.when == w)
return i;
- if (i->moment_.when < w)
+ if (i->tdescription_.when < w)
break;
}
return 0;
{
PCursor<Staff_commands_at*> i(bottom());
for (; i.ok() ; i--) {
- if (i->moment_.when < p->moment_.when)
+ if (i->tdescription_.when < p->tdescription_.when)
break;
}
if (!i.ok())
}
void
-Staff_commands::clean(Real l)
+Staff_commands::clean(Moment l)
{
PCursor<Staff_commands_at*> i(bottom());
- for (; i->moment_.when > l; i=bottom()) {
+ for (; i->tdescription_.when > l; i=bottom()) {
remove(i);
}
Staff_commands_at*p = find(l);
if (!p) {
- p = new Staff_commands_at(Moment(l - i->when(), &i->moment_));
+ p = new Staff_commands_at(Time_description(l - i->when(), &i->tdescription_));
add(p);
}
if (!p->is_breakable()) {
-#include "stcol.hh"
-#include "sccol.hh"
#include "voice.hh"
-#include "moment.hh"
+#include "timedescription.hh"
+#include "sccol.hh"
+#include "stcol.hh"
bool
Staff_column::mus() const
return score_column->musical;
}
-Real
+Moment
Staff_column::when() const
{
return score_column->when;
void
Staff_column::add(Voice_element*ve)
{
- Real d= ve->duration;
+ Moment d= ve->duration;
if (d){
score_column->add_duration(d);
}
{
score_column = s;
s_commands = 0;
- moment_ = 0;
+ tdescription_ = 0;
}
Staff_column::~Staff_column()
{
- delete moment_;
+ delete tdescription_;
}