]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.20
authorfred <fred>
Sun, 24 Mar 2002 19:27:00 +0000 (19:27 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:27:00 +0000 (19:27 +0000)
hdr/inputcommands.hh
hdr/staffcommands.hh
hdr/stcol.hh
src/inputcommands.cc
src/sccol.cc
src/staff.cc
src/staffcommands.cc
src/stcol.cc

index 527986e6ea626864ef870220f4c9c2e0fd39eebf..e2c487f2042b9ee43d98998d867409f1497609ea 100644 (file)
 #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); }    
 };
@@ -44,9 +44,9 @@ struct Input_commands : public IPointerList<Commands_at*> {
     
     /****************/
 
-    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<Commands_at*> {
     Staff_commands *parse() const;
 };
 
-
-
-void
-interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat,
-               Real& whole_per_measure);
 #endif // INPUTCOMMANDS_HH
 
index 2fb564eb625b3093dc60c27a269ab5dd36c9c617..633b73285cfb9e739d466a8940fb88b6ccc7e312 100644 (file)
@@ -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<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;
@@ -31,12 +31,12 @@ struct Staff_commands_at : public IPointerList<Command*> {
 /// 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.
index 823e9e9126a9f34a674bfb7ef67ba4bac5083210..9e7501edc752f3eb4f22946a16bb355e0cdf7fc6 100644 (file)
@@ -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);
 
     /****************************************************************
index 59d8eeaae76ad21be738a51cca901a1efecdb77a..e1d40465614488dba2792e45ef822bc04f2fc765 100644 (file)
@@ -10,21 +10,21 @@ Commands_at::print() const
 {
 #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());
     }
 }
@@ -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<Input_command*> &me(*this);
     const IPointerList<Input_command*> &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<Input_command *> 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()) <? ptr()->barleft();
+           Moment dt = (w - when()) <? ptr()->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(); 
index be242059af5d2f8193ca0126021bce5eb79239a4..ec8784a9bdf4bdf1dda20800336bc2c65136c806 100644 (file)
@@ -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])
index 03e22a03981201e8cb23b8800f385b5f82241987..ef0ff53e58707641c35eeb0a9b1b00f0e0186be9 100644 (file)
@@ -15,7 +15,7 @@ Staff::add(PointerList<Voice*> &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<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);
@@ -99,22 +99,22 @@ Staff::setup_staffcols()
     }
 
     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_);
        }
     }
 }
@@ -138,12 +138,12 @@ Staff::OK() const
 }
 
 
-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;
 }
index a0bb71f84c86f0f576a17f6411090291c67ef9cf..8a2e945e770ea843eb1af3fbb22d565c67766a09 100644 (file)
@@ -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<Command*> 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<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
@@ -224,13 +228,13 @@ Staff_commands::print() const
 }
 
 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;
@@ -241,7 +245,7 @@ Staff_commands::add(Staff_commands_at*p)
 {
     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()) 
@@ -253,16 +257,16 @@ Staff_commands::add(Staff_commands_at*p)
 }
 
 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()) {
index d4ba8cec339589edd3bb5445d8c49f28684a279a..9ed22dfe47eceeee6a150d87c014e2705aaddf9a 100644 (file)
@@ -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_;
 }