X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftime-description.cc;h=1294c6ca98114ab2b895a8169d6f101921788bd9;hb=711bbb9b9608ccd3ef2e876ab0c13af181fde283;hp=cd10942a382c0c5c06a23f24624090afbfbaa946;hpb=04f01c7e890bd4f1b358378e5911fb7c117c3802;p=lilypond.git diff --git a/lily/time-description.cc b/lily/time-description.cc index cd10942a38..1294c6ca98 100644 --- a/lily/time-description.cc +++ b/lily/time-description.cc @@ -10,133 +10,136 @@ #include "debug.hh" String -Time_description::str()const +Time_description::str() const { - String s( "Time_description { "); - if (cadenza_b_) - s+=String( " (cadenza) "); - s+= "at "; - s+=when_; - s+="\nmeter " + String(whole_per_measure_/one_beat_) +":" + - String(Rational(Rational(1)/one_beat_)); - s+= "\nposition "+String( bars_i_) + ":"+ whole_in_measure_ +"\n}\n"; - return s; + String s ("Time_description { "); + if (cadenza_b_) + s+=String (" (cadenza) "); + s+= "at "; + s+=when_; + s+="\nmeter " + String (whole_per_measure_/one_beat_) +":" + + String (Rational (Rational (1)/one_beat_)); + s+= "\nposition "+String (bars_i_) + ":"+ whole_in_measure_ +"\n}\n"; + return s; } void Time_description::print() const { #ifndef NPRINT - mtor << str(); + DOUT << str(); #endif } void Time_description::OK() const { #ifndef NDEBUG - if (!cadenza_b_) - assert(whole_in_measure_ < whole_per_measure_); - assert(Moment(0) <= whole_in_measure_); - assert(one_beat_); + if (!cadenza_b_) + assert (whole_in_measure_ < whole_per_measure_); + assert (Moment (0) <= whole_in_measure_); + assert (one_beat_); #endif } void -Time_description::set_cadenza(bool b) +Time_description::set_cadenza (bool b) { - if (cadenza_b_ && !b) { - if (whole_in_measure_) { + if (cadenza_b_ && !b) + { + if (whole_in_measure_) + { bars_i_ ++; // should do? whole_in_measure_ = 0; - } + } } - cadenza_b_ = b ; + cadenza_b_ = b ; } Time_description::Time_description() { - error_b_ = false; - whole_per_measure_ = 1; - whole_in_measure_ =0; - one_beat_ = Moment(1,4); - when_ = 0; - bars_i_ = 0; - cadenza_b_ = false; + error_b_ = false; + whole_per_measure_ = 1; + whole_in_measure_ =0; + one_beat_ = Moment (1,4); + when_ = 0; + bars_i_ = 1; // musician start counting at 1 + cadenza_b_ = false; } void -Time_description::add(Moment dt) +Time_description::add (Moment dt) { - assert(dt >= Rational(0)); - when_ += dt; - whole_in_measure_ += dt; - - while ( !cadenza_b_ && whole_in_measure_ >= whole_per_measure_ ) { + assert (dt >= Rational (0)); + when_ += dt; + whole_in_measure_ += dt; + + while (!cadenza_b_ && whole_in_measure_ >= whole_per_measure_) + { whole_in_measure_ -= whole_per_measure_; bars_i_ ++; } } void -Time_description::set_meter(int l, int o) +Time_description::set_meter (int l, int o) { - assert(o); - one_beat_ = Rational(1)/Moment(o); - whole_per_measure_ = Moment(l) * one_beat_; + assert (o); + one_beat_ = Rational (1)/Moment (o); + whole_per_measure_ = Moment (l) * one_beat_; } bool Time_description::allow_meter_change_b() { - return!(whole_in_measure_); + return!(whole_in_measure_); } /** retrieve error messages. - @return + @return error messages if not possible, "" if possible */ String -Time_description::try_set_partial_str(Moment p)const +Time_description::try_set_partial_str (Moment p) const { - if (p whole_per_measure_) - return ("Partial measure too large"); - return ""; + if (p whole_per_measure_) + return (_("Partial measure too large")); + return ""; } void -Time_description::setpartial(Moment p) +Time_description::setpartial (Moment p) { - whole_in_measure_ = whole_per_measure_ - p; + whole_in_measure_ = whole_per_measure_ - p; } Moment -Time_description::barleft()const +Time_description::barleft() const { - assert(!cadenza_b_); - return whole_per_measure_-whole_in_measure_; + assert (!cadenza_b_); + return whole_per_measure_-whole_in_measure_; } int -Time_description::compare(Time_description const &t1, Time_description const&t2) +Time_description::compare (Time_description const &t1, Time_description const&t2) { - int i = sign(t1.when_-t2.when_); - - if (!i) { - assert(t1.bars_i_==t2.bars_i_); - assert(t1.one_beat_ == t2.one_beat_); - assert(t1.whole_in_measure_ == t2.whole_in_measure_); - assert(t1.whole_per_measure_ == t2.whole_per_measure_); + int i = sign (t1.when_-t2.when_); + + if (!i) + { + assert (t1.bars_i_==t2.bars_i_); + assert (t1.one_beat_ == t2.one_beat_); + assert (t1.whole_in_measure_ == t2.whole_in_measure_); + assert (t1.whole_per_measure_ == t2.whole_per_measure_); } - return i; + return i; } Moment Time_description::next_bar_moment() const { - return when_ + barleft(); + return when_ + barleft(); } -