From 70188ea8eefe8b0a0a08fbcafbdf4db6b2649e12 Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 24 Mar 2002 19:27:00 +0000 Subject: [PATCH] lilypond-0.0.20 --- hdr/inputcommands.hh | 25 +++++++++------------- hdr/staffcommands.hh | 14 ++++++------- hdr/stcol.hh | 5 +++-- src/inputcommands.cc | 49 ++++++++++++++++++++++---------------------- src/sccol.cc | 23 +++++++++++++++------ src/staff.cc | 28 ++++++++++++------------- src/staffcommands.cc | 32 ++++++++++++++++------------- src/stcol.cc | 14 ++++++------- 8 files changed, 100 insertions(+), 90 deletions(-) diff --git a/hdr/inputcommands.hh b/hdr/inputcommands.hh index 527986e6ea..e2c487f204 100644 --- a/hdr/inputcommands.hh +++ b/hdr/inputcommands.hh @@ -11,29 +11,29 @@ #include "proto.hh" #include "plist.hh" #include "real.hh" -#include "moment.hh" +#include "timedescription.hh" struct Commands_at : public IPointerList { - 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 { /****************/ Input_cursor(PCursor); - Real when()const; - void find_moment(Real w); + Moment when()const; + void find_moment(Moment w); void prev() { operator --(0); } void next() { operator ++(0); } }; @@ -44,9 +44,9 @@ struct Input_commands : public IPointerList { /****************/ - 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&); @@ -56,10 +56,5 @@ struct Input_commands : public IPointerList { Staff_commands *parse() const; }; - - -void -interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat, - Real& whole_per_measure); #endif // INPUTCOMMANDS_HH diff --git a/hdr/staffcommands.hh b/hdr/staffcommands.hh index 2fb564eb62..633b73285c 100644 --- a/hdr/staffcommands.hh +++ b/hdr/staffcommands.hh @@ -8,17 +8,17 @@ #include "command.hh" #include "vray.hh" #include "plist.hh" -#include "moment.hh" +#include "timedescription.hh" struct Staff_commands_at : public IPointerList { - 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; @@ -31,12 +31,12 @@ struct Staff_commands_at : public IPointerList { /// the list of commands in Score struct Staff_commands : public IPointerList { - 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. diff --git a/hdr/stcol.hh b/hdr/stcol.hh index 823e9e9126..9e7501edc7 100644 --- a/hdr/stcol.hh +++ b/hdr/stcol.hh @@ -8,6 +8,7 @@ #define STCOL_HH #include "proto.hh" #include "vray.hh" +#include "moment.hh" /// store simultaneous requests struct Staff_column { @@ -20,13 +21,13 @@ 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); /**************************************************************** diff --git a/src/inputcommands.cc b/src/inputcommands.cc index 59d8eeaae7..e1d4046561 100644 --- a/src/inputcommands.cc +++ b/src/inputcommands.cc @@ -10,21 +10,21 @@ Commands_at::print() const { #ifndef NPRINT mtor << "Commands_at {"; - moment_.print(); + tdescription_.print(); for (PCursor 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()); } } @@ -38,15 +38,14 @@ Commands_at::add(Input_command *i) 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 &me(*this); const IPointerList &that(src); @@ -55,21 +54,21 @@ Commands_at::Commands_at(Commands_at const&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 cc(*this); cc.ok(); cc++) { if (cc->args.sz() && cc->args[0] !="") { Command c = **cc; @@ -81,13 +80,13 @@ Commands_at::parse(Staff_commands_at*s) /****************/ 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()) barleft(); + Moment dt = (w - when()) barleft(); Commands_at * c = new Commands_at(dt, *this); assert(c->when() <= w); @@ -103,7 +102,7 @@ Input_cursor::find_moment(Real w) } prev(); - Real dt = (w - when()); + Moment dt = (w - when()); Commands_at * c = new Commands_at(dt, *this); add(c); next(); @@ -130,10 +129,10 @@ Input_commands::Input_commands() } 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 --; } @@ -150,7 +149,7 @@ Input_commands::add(Input_command c) 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]; @@ -159,7 +158,7 @@ Input_commands::add(Input_command c) 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(); @@ -180,7 +179,7 @@ Input_commands::parse() const 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. */ @@ -208,7 +207,7 @@ Input_commands::print() const } /****************/ -Real +Moment Input_cursor::when()const { return (*this)->when(); diff --git a/src/sccol.cc b/src/sccol.cc index be242059af..ec8784a9bd 100644 --- a/src/sccol.cc +++ b/src/sccol.cc @@ -1,7 +1,18 @@ -#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); @@ -28,18 +39,18 @@ Score_column::print() const } 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]) diff --git a/src/staff.cc b/src/staff.cc index 03e22a0398..ef0ff53e58 100644 --- a/src/staff.cc +++ b/src/staff.cc @@ -15,7 +15,7 @@ Staff::add(PointerList &l) } void -Staff::process_commands(Real l) +Staff::process_commands(Moment l) { if (staff_commands_) staff_commands_->clean(l); @@ -40,7 +40,7 @@ Staff::clean_cols() } 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); @@ -89,7 +89,7 @@ void Staff::setup_staffcols() { for (PCursor i(voices); i.ok(); i++) { - Real now = i->start; + Moment now = i->start; for (PCursor ve(i->elts); ve.ok(); ve++) { Staff_column *sc=get_col(now,true); @@ -99,22 +99,22 @@ Staff::setup_staffcols() } for (PCursor 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 cc(*staff_commands_); for (PCursor 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_); } } } @@ -138,12 +138,12 @@ Staff::OK() const } -Real +Moment Staff::last() const { - Real l = 0.0; + Moment l = 0.0; for (PCursor i(voices); i.ok(); i++) { - l = MAX(l, i->last()); + l = l >? i->last(); } return l; } diff --git a/src/staffcommands.cc b/src/staffcommands.cc index a0bb71f84c..8a2e945e77 100644 --- a/src/staffcommands.cc +++ b/src/staffcommands.cc @@ -2,10 +2,10 @@ #include "debug.hh" #include "parseconstruct.hh" -Real +Moment Staff_commands_at::when() { - return moment_.when; + return tdescription_.when; } void Staff_commands_at::print() const @@ -13,7 +13,7 @@ Staff_commands_at::print() const #ifndef NPRINT PCursor i (*this); mtor << "Commands at: " ; - moment_.print(); + tdescription_.print(); for (; i.ok(); i++) i->print(); @@ -28,8 +28,8 @@ Staff_commands_at::OK()const 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) { } @@ -105,7 +105,11 @@ Staff_commands_at::add_command_to_break(Command pre, Command mid,Command post) insert_between(post, f, l); } - + + +/* + should move this stuff into inputlanguage. + */ void Staff_commands_at::add(Command c) { @@ -207,7 +211,7 @@ Staff_commands::OK() const { #ifndef NDEBUG for (PCursor 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 @@ -224,13 +228,13 @@ Staff_commands::print() const } Staff_commands_at* -Staff_commands::find(Real w) +Staff_commands::find(Moment w) { PCursor 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; @@ -241,7 +245,7 @@ Staff_commands::add(Staff_commands_at*p) { PCursor i(bottom()); for (; i.ok() ; i--) { - if (i->moment_.when < p->moment_.when) + if (i->tdescription_.when < p->tdescription_.when) break; } if (!i.ok()) @@ -253,16 +257,16 @@ Staff_commands::add(Staff_commands_at*p) } void -Staff_commands::clean(Real l) +Staff_commands::clean(Moment l) { PCursor 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()) { diff --git a/src/stcol.cc b/src/stcol.cc index d4ba8cec33..9ed22dfe47 100644 --- a/src/stcol.cc +++ b/src/stcol.cc @@ -1,7 +1,7 @@ -#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 @@ -9,7 +9,7 @@ Staff_column::mus() const return score_column->musical; } -Real +Moment Staff_column::when() const { return score_column->when; @@ -18,7 +18,7 @@ Staff_column::when() const void Staff_column::add(Voice_element*ve) { - Real d= ve->duration; + Moment d= ve->duration; if (d){ score_column->add_duration(d); } @@ -30,10 +30,10 @@ Staff_column::Staff_column(Score_column*s) { score_column = s; s_commands = 0; - moment_ = 0; + tdescription_ = 0; } Staff_column::~Staff_column() { - delete moment_; + delete tdescription_; } -- 2.39.5