From 3a46c107cba4b3d2dba74e21f9046cc399c8baf1 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 6 Feb 1999 17:09:10 +0100 Subject: [PATCH] patch::: 1.1.27.jcn2: hat pl 27.jcn2 - grand renaming: Duration vs Moment / Rational --- NEWS | 3 + VERSION | 2 +- lib/duration-convert.cc | 6 +- lib/duration.cc | 4 +- lib/include/duration.hh | 2 +- lily/auto-beam-engraver.cc | 14 +- lily/bar-engraver.cc | 2 +- lily/bar-number-engraver.cc | 2 +- lily/beam-engraver.cc | 6 +- lily/beam.cc | 2 +- lily/command-request.cc | 8 +- lily/global-translator.cc | 2 +- lily/grouping.cc | 383 ------------------------ lily/include/command-request.hh | 2 +- lily/include/global-translator.hh | 2 +- lily/include/grouping.hh | 60 ---- lily/include/midi-def.hh | 2 +- lily/include/midi-item.hh | 2 +- lily/include/music-list.hh | 4 +- lily/include/music-wrapper.hh | 2 +- lily/include/music.hh | 2 +- lily/include/musical-request.hh | 2 +- lily/include/paper-def.hh | 2 +- lily/include/repeated-music.hh | 2 +- lily/include/request-iterator.hh | 4 +- lily/include/rhythmic-grouping.hh | 60 ++++ lily/include/time-signature-engraver.hh | 2 +- lily/include/timing-translator.hh | 2 +- lily/include/translator.hh | 2 +- lily/midi-def.cc | 2 +- lily/midi-item.cc | 4 +- lily/midi-walker.cc | 2 +- lily/multi-measure-rest-engraver.cc | 10 +- lily/music-list.cc | 8 +- lily/music-wrapper.cc | 4 +- lily/music.cc | 2 +- lily/musical-request.cc | 8 +- lily/paper-def.cc | 2 +- lily/parser.yy | 4 +- lily/repeat-engraver.cc | 18 +- lily/repeated-music-iterator.cc | 12 +- lily/repeated-music.cc | 6 +- lily/request-iterator.cc | 10 +- lily/rhythmic-grouping.cc | 383 ++++++++++++++++++++++++ lily/score-engraver.cc | 2 +- lily/score.cc | 2 +- lily/sequential-music-iterator.cc | 2 +- lily/spring-spacer.cc | 4 +- lily/staff-margin-engraver.cc | 2 +- lily/tie-engraver.cc | 6 +- lily/time-description.cc | 8 +- lily/timing-translator.cc | 6 +- lily/translator-group.cc | 2 +- lily/translator.cc | 4 +- lily/tuplet-engraver.cc | 4 +- 55 files changed, 553 insertions(+), 552 deletions(-) create mode 100644 lily/include/rhythmic-grouping.hh create mode 100644 lily/rhythmic-grouping.cc diff --git a/NEWS b/NEWS index 944aa057e1..6e5bc43731 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +pl 27.jcn2 + - grand renaming: Duration vs Moment / Rational + pl 27.jcn1 - complete redo of chord and chord name code - small fixes diff --git a/VERSION b/VERSION index 9a0ab9447e..690b6a3931 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=1 PATCH_LEVEL=27 -MY_PATCH_LEVEL=jcn1 +MY_PATCH_LEVEL=jcn2 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/lib/duration-convert.cc b/lib/duration-convert.cc index c1240f3cdd..4f2e2a9015 100644 --- a/lib/duration-convert.cc +++ b/lib/duration-convert.cc @@ -105,14 +105,14 @@ Duration_convert::mom2_dur (Moment mom) Duration dur = mom2standardised_dur (mom); // if (!dur.mom () || (dur.mom () == mom)) - if (!dur.length () || (dur.length () == mom)) + if (!dur.length_mom () || (dur.length_mom () == mom)) return dur; assert (midi_as_plet_b_s); // dur.set_plet (type_mom, Duration::division_1_i_s / 4); // Moment as_plet_mom = mom / dur.mom (); - Moment as_plet_mom = mom / dur.length (); + Moment as_plet_mom = mom / dur.length_mom (); as_plet_mom *= dur.plet_.mom (); long num = as_plet_mom.num (); long den = as_plet_mom.den (); @@ -185,7 +185,7 @@ Duration_convert::ticks2_dur (int ticks_i) Duration dur = mom2standardised_dur (mom); - if (dur.length () == mom) + if (dur.length_mom () == mom) return dur; return mom2_dur (mom); diff --git a/lib/duration.cc b/lib/duration.cc index f65348ae6d..8e254ba0f2 100644 --- a/lib/duration.cc +++ b/lib/duration.cc @@ -45,10 +45,8 @@ Duration::compress (Moment m) plet_.type_i_ *= m.den_i (); } -// ugh, what's this? -// i should be called "mom ()", ... or at least "length_mom ()" Moment -Duration::length () const +Duration::length_mom () const { return Duration_convert::dur2_mom (*this); } diff --git a/lib/include/duration.hh b/lib/include/duration.hh index 509a6d69d9..1ece5771d8 100644 --- a/lib/include/duration.hh +++ b/lib/include/duration.hh @@ -31,7 +31,7 @@ struct Duration { static bool duration_type_b (int t); void set_ticks (int ticks_i ); - Moment length () const ; // zo naai mij + Moment length_mom () const ; static int division_1_i_s; /// Logarithm of the base duration. diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index 23698891e4..9536e17ace 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -11,7 +11,7 @@ #include "musical-request.hh" #include "bar.hh" #include "beam.hh" -#include "grouping.hh" +#include "rhythmic-grouping.hh" #include "rest.hh" #include "stem.hh" #include "debug.hh" @@ -83,7 +83,7 @@ Auto_beam_engraver::consider_end_and_begin () void Auto_beam_engraver::begin_beam () { - DOUT << String ("starting autobeam at: ") + now_moment ().str () + "\n"; + DOUT << String ("starting autobeam at: ") + now_mom ().str () + "\n"; beam_p_ = new Beam; grouping_p_ = new Rhythmic_grouping; @@ -112,7 +112,7 @@ Auto_beam_engraver::begin_beam () void Auto_beam_engraver::end_beam () { - DOUT << String ("ending autobeam at: ") + now_moment ().str () + "\n"; + DOUT << String ("ending autobeam at: ") + now_mom ().str () + "\n"; if (beam_p_->stems_.size () < 2) { DOUT << "junking autombeam: less than two stems\n"; @@ -241,12 +241,12 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info) consider_end_and_begin (); } mult_i_ = m; - grouping_p_->add_child (start, rhythmic_req->duration ()); + grouping_p_->add_child (start, rhythmic_req->length_mom ()); stem_l->flag_i_ = rhythmic_req->duration_.durlog_i_; beam_p_->add_stem (stem_l); - Moment now = now_moment (); + Moment now = now_mom (); last_add_mom_ = now; - extend_mom_ = extend_mom_ >? now + rhythmic_req->duration (); + extend_mom_ = extend_mom_ >? now + rhythmic_req->length_mom (); } } } @@ -276,7 +276,7 @@ Auto_beam_engraver::process_acknowledged () { if (beam_p_) { - Moment now = now_moment (); + Moment now = now_mom (); if ((extend_mom_ < now) || ((extend_mom_ == now) && (last_add_mom_ != now ))) { diff --git a/lily/bar-engraver.cc b/lily/bar-engraver.cc index 57436ae70f..d81cafb294 100644 --- a/lily/bar-engraver.cc +++ b/lily/bar-engraver.cc @@ -104,7 +104,7 @@ Bar_engraver::do_process_requests() create_bar (); bar_p_->type_str_ = bar_req_l_->type_str_; } - else if (!now_moment ()) + else if (!now_mom ()) { create_bar (); bar_p_->type_str_ = ""; diff --git a/lily/bar-number-engraver.cc b/lily/bar-number-engraver.cc index 7adc8dcdea..54ef0e0c77 100644 --- a/lily/bar-number-engraver.cc +++ b/lily/bar-number-engraver.cc @@ -28,7 +28,7 @@ Bar_number_engraver::do_process_requests () Timing_translator *timer = dynamic_cast(tr); Time_description *time = &timer->time_; - if (!time->whole_in_measure_ && !time->cadenza_b_ && now_moment () > Moment (0)) + if (!time->whole_in_measure_ && !time->cadenza_b_ && now_mom () > Moment (0)) { create_items (0); diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index ac7a02a26b..66a90faec7 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -10,7 +10,7 @@ #include "beam-engraver.hh" #include "musical-request.hh" #include "beam.hh" -#include "grouping.hh" +#include "rhythmic-grouping.hh" #include "stem.hh" #include "warn.hh" #include "time-description.hh" @@ -171,7 +171,7 @@ Beam_engraver::acknowledge_element (Score_element_info info) if (!grouping_p_->child_fit_b (start)) { String s (_ ("please fix me") + ": " - + _f ("stem at %s doesn't fit in beam", now_moment ().str ())); + + _f ("stem at %s doesn't fit in beam", now_mom ().str ())); if (info.req_l_) info.req_l_->warning(s); @@ -180,7 +180,7 @@ Beam_engraver::acknowledge_element (Score_element_info info) } else { - grouping_p_->add_child (start, rhythmic_req->duration ()); + grouping_p_->add_child (start, rhythmic_req->length_mom ()); stem_l->flag_i_ = rhythmic_req->duration_.durlog_i_; beam_p_->add_stem (stem_l); } diff --git a/lily/beam.cc b/lily/beam.cc index 90476e1e9f..0c4447664e 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -32,7 +32,7 @@ #include "stem.hh" #include "paper-def.hh" #include "lookup.hh" -#include "grouping.hh" +#include "rhythmic-grouping.hh" Beam::Beam () { diff --git a/lily/command-request.cc b/lily/command-request.cc index 1ab0353bc5..aa5b3877d7 100644 --- a/lily/command-request.cc +++ b/lily/command-request.cc @@ -74,7 +74,7 @@ Bar_req::Bar_req (String s) Partial_measure_req::Partial_measure_req (Moment m) { - duration_ =m; + length_mom_ =m; } bool @@ -82,7 +82,7 @@ Partial_measure_req::do_equal_b (Request* r) const { Partial_measure_req *p = dynamic_cast (r); - return p&& p->duration_ == duration_; + return p&& p->length_mom_ == length_mom_; } @@ -133,7 +133,7 @@ Clef_change_req::Clef_change_req (String s) void Partial_measure_req::do_print() const { - DOUT << duration_; + DOUT << length_mom_; } @@ -181,7 +181,7 @@ Tempo_req::do_equal_b (Request *r) const { Tempo_req *t = dynamic_cast (r); - return t&& t->dur_.length()== dur_.length () && metronome_i_ == t->metronome_i_; + return t&& t->dur_.length_mom ()== dur_.length_mom () && metronome_i_ == t->metronome_i_; } diff --git a/lily/global-translator.cc b/lily/global-translator.cc index d6785e6d05..b92a7a992a 100644 --- a/lily/global-translator.cc +++ b/lily/global-translator.cc @@ -47,7 +47,7 @@ Global_translator::prepare (Moment m) } Moment -Global_translator::now_moment () const +Global_translator::now_mom () const { return now_mom_; } diff --git a/lily/grouping.cc b/lily/grouping.cc index af7d234bf4..e69de29bb2 100644 --- a/lily/grouping.cc +++ b/lily/grouping.cc @@ -1,383 +0,0 @@ -/* - grouping.cc -- implement Rhythmic_grouping - - source file of the GNU LilyPond music typesetter - - (c) 1997--1998 Han-Wen Nienhuys -*/ - -#include "debug.hh" -#include "grouping.hh" -#include "interval.hh" - -void -Rhythmic_grouping::init() -{ - interval_ = 0; - children.clear(); -} - -void -Rhythmic_grouping::OK() const -{ -#ifndef NDEBUG - assert (bool (children.size()) != bool (interval_)); - - for (int i= 0; i < children.size(); i++) - { - children[i]->OK(); - if (i>0) - assert (children[i-1]->interval().right == - children[i]->interval().left); - } -#endif -} - -Moment -Rhythmic_grouping::length() const -{ - return interval().length (); -} - -MInterval -Rhythmic_grouping::interval() const -{ - if (interval_) - return *interval_; - else - return - MInterval (children[0]->interval().left, - children.top()->interval ().right); -} - -void -Rhythmic_grouping::split (Rhythmic_grouping r) -{ - if (interval_) - return ; - - r.intersect (interval()); - split (r.intervals()); - - for (int i= 0; i < children.size(); i++) - { - if (!children[i]->interval_) - { - Rhythmic_grouping here (r); - children[i]->split (here); - } - } -} - - -Array -Rhythmic_grouping::intervals() -{ - Array r; - if (interval_ || children.size() == 1) - { - MInterval i (interval()); - MInterval r1(i), r2(i); - r1.right = r2.left = i.center(); - r.push (r1); r.push (r2); - } - else - { - for (int i=0; i < children.size(); i++) - r.push (children[i]->interval()); - } - return r; -} - -void -Rhythmic_grouping::intersect (MInterval t) -{ - if (interval_) - { - interval_->intersect (t); - return; - } - - for (int i=0; i < children.size(); i++) - { - MInterval inter = intersection (t, children[i]->interval()); - if (inter.empty_b() || inter.length () <= Rational (0)) - { - delete children[i]; - children[i] =0; - } - else - { - children[i]->intersect (t); - } - } - for (int i=0; i < children.size();) - { - if (!children[i]) - children.del (i); - else - i++; - } - -} - -/** - Put our children in branches of #this#. - The min and max time intervals coincide with elements of #splitpoints# - - I really should be documenting what is happening here, but I find - that difficult, since I don't really understand what's going on here. - - */ -void -Rhythmic_grouping::split (Array splitpoints) -{ - //check on splitpoints.. - int j = 0, i = 0, starti = 0, startj = 0; - - Array ch; - while (1) - { - if (i >= children.size() || j >= splitpoints.size ()) - break; - - assert ( - children[starti]->interval().left== splitpoints[startj].left); - if (children[i]->interval().right < splitpoints[j].right) - { - i ++; - } - else if (children[i]->interval().right > splitpoints[j].right) - { - j ++; - } - else - { - - if (i == starti) - { - ch.push (children[i]); - } - else - { - Rhythmic_grouping *newchild=new Rhythmic_grouping ( - children.slice (starti, i+1)); - - ch.push (newchild); - } - i ++; - j++; - starti = i; - startj = j; - - - } - } - if (ch.size() != 1) - children = ch; -} - - -Rhythmic_grouping::Rhythmic_grouping (MInterval t, int n) -{ - init(); - if (n == 1 || !n) - { - interval_ = new MInterval (t); - return; - } - Moment dt = t.length()/Rational (n); - MInterval basic = MInterval (t.left, t.left+dt); - for (int i= 0; i < n; i++) - children.push (new Rhythmic_grouping (dt*Rational (i) + basic)); -} - - -Rhythmic_grouping::Rhythmic_grouping (Array r) - :children (r) -{ - interval_ =0; -} - -Rhythmic_grouping::~Rhythmic_grouping() -{ - junk(); -} - -void -Rhythmic_grouping::copy (Rhythmic_grouping const&s) -{ - interval_ = (s.interval_)? new MInterval (*s.interval_) : 0; - for (int i=0; i < s.children.size(); i++) - children.push (new Rhythmic_grouping (*s.children[i])); -} - -void -Rhythmic_grouping::operator=(Rhythmic_grouping const &s) -{ - junk(); - copy (s); -} - -Rhythmic_grouping::Rhythmic_grouping (Rhythmic_grouping const&s) -{ - init(); - copy (s); -} - -void -Rhythmic_grouping::junk() -{ - delete interval_; - for (int i=0; i < children.size(); i++) - delete children[i]; - init(); -} - -void -Rhythmic_grouping::print() const -{ -#ifndef NPRINT - DOUT << "{ \n"; - if (interval_) - DOUT <<" Interval "<< interval_->str(); - for (int i=0; i < children.size(); i++) - { - children[i]->print(); - } - DOUT << "}\n"; -#endif -} - -bool -Rhythmic_grouping::child_fit_b (Moment start) -{ - if (children.size()) - return (children.top()->interval ().right== start); - - return true; -} - -void -Rhythmic_grouping::add_child (Moment start, Moment len) -{ - Moment stop = start+len; - assert (child_fit_b (start)); - children.push (new Rhythmic_grouping (MInterval (start, stop))); -} - -Rhythmic_grouping::Rhythmic_grouping() -{ - interval_ =0; -} - -int -min_elt (Array v) -{ - int i = 1000; // ugh - for (int j = 0 ; j < v.size(); j++) - i = i -Rhythmic_grouping::generate_beams (Array flags, int &flagidx) -{ - assert (!interval_) ; - - Array< Array > children_beams; - for (int i=0; i < children.size(); i++) - { - Array child_beams; - if (children[i]->interval_) - { - int f = flags[flagidx++]; - child_beams.push (f); - } - else - { - child_beams = children[i]-> - generate_beams (flags, flagidx); - } - children_beams.push (child_beams); - } - Array beams; - int lastm, m, nextm; - for (int i=0; i < children_beams.size(); i++) - { - bool add_left = (i >0); - bool add_right = (i < children_beams.size() -1); - - if (!i) - m = min_elt (children_beams[i]); - if (add_right) - nextm = min_elt (children_beams[i+1]); - - if (children_beams[i].size() == 1) - { - if (add_right) - beams.push (m); - if (add_left) - beams.push (m); - } - else - { - if (add_left) - beams.push (lastm translate (m); -} - -void -Rhythmic_grouping::extend (MInterval m) const -{ - assert (m.left >= interval().left); - while (m.right >interval().right) - { - Array a (children); - for (int i=0; i < a.size(); i++) - { - a[i] =new Rhythmic_grouping (*children[i]); - a[i]->translate (children.top()->interval ().right); - } - ((Rhythmic_grouping*)this)->children.concat (a); - } - assert (m.right <= interval().right); - OK(); -} - -Rhythmic_grouping -parse_grouping (Array beat_i_arr, Array elt_length_arr) -{ - Moment here =0; - assert (beat_i_arr.size() == elt_length_arr.size ()); - - Array children; - for (int i=0; i < beat_i_arr.size(); i++) - { - Moment last = here; - here += elt_length_arr[i] * Moment (beat_i_arr[i]); - children.push ( - new Rhythmic_grouping (MInterval (last, here), - beat_i_arr[i])); - } - return Rhythmic_grouping (children); -} - diff --git a/lily/include/command-request.hh b/lily/include/command-request.hh index 7d539fb666..cf3c897efc 100644 --- a/lily/include/command-request.hh +++ b/lily/include/command-request.hh @@ -69,7 +69,7 @@ public: class Partial_measure_req : public Timing_req { public: - Moment duration_; + Moment length_mom_; Partial_measure_req (Moment); REQUESTMETHODS(Partial_measure_req); diff --git a/lily/include/global-translator.hh b/lily/include/global-translator.hh index 0e12f150fd..7028dbc92f 100644 --- a/lily/include/global-translator.hh +++ b/lily/include/global-translator.hh @@ -34,7 +34,7 @@ public: protected: - virtual Moment now_moment () const; + virtual Moment now_mom () const; virtual Global_translator *global_l() { return this; } }; diff --git a/lily/include/grouping.hh b/lily/include/grouping.hh index ada7b4ab5c..e69de29bb2 100644 --- a/lily/include/grouping.hh +++ b/lily/include/grouping.hh @@ -1,60 +0,0 @@ -/* - grouping.hh -- part of GNU LilyPond - - (c) 1996--1998 Han-Wen Nienhuys -*/ - -#ifndef GROUPING_HH -#define GROUPING_HH - -#include "minterval.hh" -#include "array.hh" - -/** data structure which represents rhythmic units this is a tree. It groupes notes according to rules - - TODO Documentation. Unhairing - */ -struct Rhythmic_grouping { - Array children; - MInterval *interval_; - - - Array intervals(); - MInterval interval() const; - Moment length() const; - void intersect (MInterval); - - void operator=(Rhythmic_grouping const&); - Rhythmic_grouping (Rhythmic_grouping const&); - Rhythmic_grouping (MInterval, int n=1); - Rhythmic_grouping(); - Rhythmic_grouping (Array); - ~Rhythmic_grouping(); - - void add_child (Moment start, Moment len); - bool child_fit_b (Moment start); - void split (Rhythmic_grouping r); - void split (Array); - void split (int n); - - void print() const; - void OK() const; - - Array generate_beams (Array, int&); - - /** multiply self to span #i#. - In implementation, this isn't really const, but conceptually it is. - */ - void extend (MInterval i) const; - void translate (Moment); -private: - void init(); - void junk(); - void copy (Rhythmic_grouping const&); -}; - - -Rhythmic_grouping parse_grouping (Array beat_i_arr, Array elt_length_arr); - - -#endif diff --git a/lily/include/midi-def.hh b/lily/include/midi-def.hh index ef0029b418..85975ee8dd 100644 --- a/lily/include/midi-def.hh +++ b/lily/include/midi-def.hh @@ -31,7 +31,7 @@ public: Midi_def(); ~Midi_def(); - Real duration_to_seconds_f (Moment); + Real length_mom_to_seconds_f (Moment); int get_tempo_i (Moment moment); void print() const; void set_tempo (Moment moment, int count_per_minute_i); diff --git a/lily/include/midi-item.hh b/lily/include/midi-item.hh index 5b3eaf6a1a..2b251c4286 100644 --- a/lily/include/midi-item.hh +++ b/lily/include/midi-item.hh @@ -112,7 +112,7 @@ struct Midi_note : public Midi_item { Midi_note (Audio_item* audio_item_l); - Moment duration () const; + Moment length_mom () const; int pitch_i () const; virtual String str () const; diff --git a/lily/include/music-list.hh b/lily/include/music-list.hh index 7cbbffee49..9665ff9df4 100644 --- a/lily/include/music-list.hh +++ b/lily/include/music-list.hh @@ -55,7 +55,7 @@ public: Simultaneous_music(Music_list *); virtual Musical_pitch to_relative_octave (Musical_pitch); - virtual Moment duration () const; + virtual Moment length_mom () const; }; @@ -84,6 +84,6 @@ public: virtual Musical_pitch to_relative_octave (Musical_pitch); Sequential_music(Music_list*); - virtual Moment duration () const; + virtual Moment length_mom () const; }; #endif // Music_sequence_HH diff --git a/lily/include/music-wrapper.hh b/lily/include/music-wrapper.hh index 26fea0ec7b..adbd869790 100644 --- a/lily/include/music-wrapper.hh +++ b/lily/include/music-wrapper.hh @@ -30,7 +30,7 @@ public: VIRTUAL_COPY_CONS(Music); Music_wrapper (Music_wrapper const&); - virtual Moment duration () const; + virtual Moment length_mom () const; virtual ~Music_wrapper (); virtual Musical_pitch to_relative_octave (Musical_pitch); diff --git a/lily/include/music.hh b/lily/include/music.hh index 8f30e44698..15ee2f7074 100644 --- a/lily/include/music.hh +++ b/lily/include/music.hh @@ -44,7 +44,7 @@ public: virtual Musical_pitch to_relative_octave (Musical_pitch); /// The duration of this piece of music - virtual Moment duration () const; + virtual Moment length_mom () const; virtual ~Music(){} void print() const; diff --git a/lily/include/musical-request.hh b/lily/include/musical-request.hh index 3fcf3b9cd6..eea7e90b16 100644 --- a/lily/include/musical-request.hh +++ b/lily/include/musical-request.hh @@ -37,7 +37,7 @@ public: bool do_equal_b (Request*) const; void compress (Moment); - virtual Moment duration() const; + virtual Moment length_mom () const; static int compare (Rhythmic_req const&,Rhythmic_req const&); REQUESTMETHODS(Rhythmic_req); }; diff --git a/lily/include/paper-def.hh b/lily/include/paper-def.hh index df73bea785..4364350592 100644 --- a/lily/include/paper-def.hh +++ b/lily/include/paper-def.hh @@ -86,7 +86,7 @@ public: /** convert a duration to an idealspacing influence using the geometric_ and paratime_signatures. */ - Real duration_to_dist (Moment, Real) const; + Real length_mom_to_dist (Moment, Real) const; Real geometric_spacing (Moment) const; Real arithmetic_constant (Moment minimal_mom) const; Real arithmetic_spacing (Moment mom,Real constant) const; diff --git a/lily/include/repeated-music.hh b/lily/include/repeated-music.hh index 6175d45864..5e2e2b28c7 100644 --- a/lily/include/repeated-music.hh +++ b/lily/include/repeated-music.hh @@ -29,7 +29,7 @@ public: virtual void do_print () const; virtual void transpose (Musical_pitch p); - virtual Moment duration () const; + virtual Moment length_mom () const; virtual Musical_pitch to_relative_octave (Musical_pitch p); VIRTUAL_COPY_CONS(Music); }; diff --git a/lily/include/request-iterator.hh b/lily/include/request-iterator.hh index d374d5929f..4d078dca46 100644 --- a/lily/include/request-iterator.hh +++ b/lily/include/request-iterator.hh @@ -18,9 +18,9 @@ class Request_chord_iterator : public Music_iterator { Request_chord * elt_l () const; /** - cache elt_l ()->duration (). + cache elt_l ()->length_mom (). */ - Moment elt_duration_; + Moment elt_length_mom_; bool last_b_; public: diff --git a/lily/include/rhythmic-grouping.hh b/lily/include/rhythmic-grouping.hh new file mode 100644 index 0000000000..07bca7b9ac --- /dev/null +++ b/lily/include/rhythmic-grouping.hh @@ -0,0 +1,60 @@ +/* + rhythmic-grouping.hh -- part of GNU LilyPond + + (c) 1996--1998 Han-Wen Nienhuys +*/ + +#ifndef RHYTHMIC_GROUPING_HH +#define RHYTHMIC_GROUPING_HH + +#include "minterval.hh" +#include "array.hh" + +/** data structure which represents rhythmic units this is a tree. It groupes notes according to rules + + TODO Documentation. Unhairing + */ +struct Rhythmic_grouping { + Array children; + MInterval *interval_; + + + Array intervals(); + MInterval interval() const; + Moment length_mom () const; + void intersect (MInterval); + + void operator=(Rhythmic_grouping const&); + Rhythmic_grouping (Rhythmic_grouping const&); + Rhythmic_grouping (MInterval, int n=1); + Rhythmic_grouping(); + Rhythmic_grouping (Array); + ~Rhythmic_grouping(); + + void add_child (Moment start, Moment len); + bool child_fit_b (Moment start); + void split (Rhythmic_grouping r); + void split (Array); + void split (int n); + + void print() const; + void OK() const; + + Array generate_beams (Array, int&); + + /** multiply self to span #i#. + In implementation, this isn't really const, but conceptually it is. + */ + void extend (MInterval i) const; + void translate (Moment); +private: + void init(); + void junk(); + void copy (Rhythmic_grouping const&); +}; + + +Rhythmic_grouping parse_grouping (Array beat_i_arr, Array elt_length_arr); + + +#endif // RHYTHMIC_GROUPING_HH diff --git a/lily/include/time-signature-engraver.hh b/lily/include/time-signature-engraver.hh index 460939d59b..2fc7a6497f 100644 --- a/lily/include/time-signature-engraver.hh +++ b/lily/include/time-signature-engraver.hh @@ -11,7 +11,7 @@ #define METERGRAV_HH #include "engraver.hh" #include "time-description.hh" -#include "grouping.hh" +#include "rhythmic-grouping.hh" /** generate time_signatures. diff --git a/lily/include/timing-translator.hh b/lily/include/timing-translator.hh index 7074d9c873..2e97184c5f 100644 --- a/lily/include/timing-translator.hh +++ b/lily/include/timing-translator.hh @@ -12,7 +12,7 @@ #include "translator.hh" #include "time-description.hh" -#include "grouping.hh" +#include "rhythmic-grouping.hh" #include "parray.hh" class Timing_translator : public virtual Translator diff --git a/lily/include/translator.hh b/lily/include/translator.hh index f089df51b4..997735483a 100644 --- a/lily/include/translator.hh +++ b/lily/include/translator.hh @@ -61,7 +61,7 @@ public: */ Music_output_def *output_def_l () const; Scalar get_property (String, Translator_group **) const; - virtual Moment now_moment () const; + virtual Moment now_mom () const; protected: enum { diff --git a/lily/midi-def.cc b/lily/midi-def.cc index e121621593..81ea51e5af 100644 --- a/lily/midi-def.cc +++ b/lily/midi-def.cc @@ -31,7 +31,7 @@ Midi_def::~Midi_def() } Real -Midi_def::duration_to_seconds_f (Moment mom) +Midi_def::length_mom_to_seconds_f (Moment mom) { if (!mom) return 0; diff --git a/lily/midi-item.cc b/lily/midi-item.cc index 106ee8bcba..2dd86eddc1 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -403,9 +403,9 @@ Midi_note::Midi_note (Audio_item* audio_item_l) } Moment -Midi_note::duration () const +Midi_note::length_mom () const { - Moment m = dynamic_cast (audio_item_l_->req_l_)->duration (); + Moment m = dynamic_cast (audio_item_l_->req_l_)->length_mom (); if (m < Moment (1, 1000)) { warning (_ ("silly duration")); diff --git a/lily/midi-walker.cc b/lily/midi-walker.cc index 1af44cd1fb..3709fc755c 100644 --- a/lily/midi-walker.cc +++ b/lily/midi-walker.cc @@ -45,7 +45,7 @@ Midi_walker::~Midi_walker() void Midi_walker::do_start_note (Midi_note* note_p) { - Moment stop_mom = note_p->duration() + ptr ()->audio_column_l_->at_mom (); + Moment stop_mom = note_p->length_mom () + ptr ()->audio_column_l_->at_mom (); for (int i=0; i < stop_note_queue.size(); i++) { if (stop_note_queue[i].val->pitch_i() == note_p->pitch_i ()) diff --git a/lily/multi-measure-rest-engraver.cc b/lily/multi-measure-rest-engraver.cc index 8dd071d6d5..0143543c6e 100644 --- a/lily/multi-measure-rest-engraver.cc +++ b/lily/multi-measure-rest-engraver.cc @@ -49,13 +49,13 @@ Multi_measure_rest_engraver::do_try_music (Music* req_l) { if (multi_measure_req_l_) if (!multi_measure_req_l_->equal_b (mr) - || rest_moments_[START] != now_moment ()) + || rest_moments_[START] != now_mom ()) return false; multi_measure_req_l_ = mr; - rest_moments_[START] = now_moment (); + rest_moments_[START] = now_mom (); - rest_moments_[STOP] = rest_moments_[START] + multi_measure_req_l_->duration_.length (); + rest_moments_[STOP] = rest_moments_[START] + multi_measure_req_l_->duration_.length_mom (); return true; } return false; @@ -76,7 +76,7 @@ Multi_measure_rest_engraver::do_process_requests () void Multi_measure_rest_engraver::do_pre_move_processing () { - Moment now (now_moment ()); + Moment now (now_mom ()); Time_description const *time = get_staff_info().time_C_; if (mmrest_p_ && (now >= rest_moments_[START]) && !time->whole_in_measure_ @@ -98,7 +98,7 @@ void Multi_measure_rest_engraver::do_post_move_processing () { Time_description const *time = get_staff_info().time_C_; - Moment now (now_moment ()); + Moment now (now_mom ()); if (mmrest_p_ && !time->whole_in_measure_) { diff --git a/lily/music-list.cc b/lily/music-list.cc index 3d155a90c6..bf409cb878 100644 --- a/lily/music-list.cc +++ b/lily/music-list.cc @@ -13,11 +13,11 @@ #include "main.hh" Moment -Simultaneous_music::duration () const +Simultaneous_music::length_mom () const { Moment dur = 0; for (iter (music_p_list_p_->top(), i); i.ok (); i++) - dur = dur >? i->duration (); + dur = dur >? i->length_mom (); return dur; } @@ -41,12 +41,12 @@ Sequential_music::Sequential_music(Music_list *p) } Moment -Sequential_music::duration () const +Sequential_music::length_mom () const { Moment last=0; for (iter (music_p_list_p_->top(), i); i.ok (); i++) { - last += i->duration (); + last += i->length_mom (); } return last; } diff --git a/lily/music-wrapper.cc b/lily/music-wrapper.cc index 57ab04b741..b84394d86d 100644 --- a/lily/music-wrapper.cc +++ b/lily/music-wrapper.cc @@ -45,9 +45,9 @@ Music_wrapper::Music_wrapper(Music*p) Moment -Music_wrapper::duration () const +Music_wrapper::length_mom () const { - return element_p_->duration (); + return element_p_->length_mom (); } diff --git a/lily/music.cc b/lily/music.cc index 8d7ce5cb88..ffecc3fafd 100644 --- a/lily/music.cc +++ b/lily/music.cc @@ -27,7 +27,7 @@ Music::do_print() const } Moment -Music::duration () const +Music::length_mom () const { return 0; } diff --git a/lily/musical-request.cc b/lily/musical-request.cc index b573a4f264..574e08dcad 100644 --- a/lily/musical-request.cc +++ b/lily/musical-request.cc @@ -136,7 +136,7 @@ Tonic_req::do_print () const int Rhythmic_req::compare (Rhythmic_req const &r1, Rhythmic_req const &r2) { - return (r1.duration () - r2.duration ()); + return (r1.length_mom () - r2.length_mom ()); } bool @@ -160,9 +160,9 @@ Rhythmic_req::do_print () const Moment -Rhythmic_req::duration () const +Rhythmic_req::length_mom () const { - return duration_.length (); + return duration_.length_mom (); } void @@ -322,7 +322,7 @@ void Skip_req::do_print () const { #ifndef NPRINT - DOUT << "duration: " << duration (); + DOUT << "duration: " << length_mom (); #endif } diff --git a/lily/paper-def.cc b/lily/paper-def.cc index 626881eea5..8f6cefcc49 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -109,7 +109,7 @@ SCMVAR(linewidth); } Real -Paper_def::duration_to_dist (Moment d,Real k) const +Paper_def::length_mom_to_dist (Moment d,Real k) const { return arithmetic_spacing (d,k); } diff --git a/lily/parser.yy b/lily/parser.yy index 73a7557a47..d7891b9b37 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -690,7 +690,7 @@ midi_body: /* empty */ { $$-> assign_translator ($2); } | midi_body tempo_request ';' { - $$->set_tempo ($2->dur_.length (), $2->metronome_i_); + $$->set_tempo ($2->dur_.length_mom (), $2->metronome_i_); delete $2; } | midi_body error { @@ -946,7 +946,7 @@ verbose_command_req: $$ = new Cadenza_req ($2); } | PARTIAL duration_length { - $$ = new Partial_measure_req ($2->length ()); + $$ = new Partial_measure_req ($2->length_mom ()); delete $2; } | CLEF STRING { diff --git a/lily/repeat-engraver.cc b/lily/repeat-engraver.cc index ab634c71da..2fb69d16af 100644 --- a/lily/repeat-engraver.cc +++ b/lily/repeat-engraver.cc @@ -36,14 +36,14 @@ Repeat_engraver::do_try_music (Music* m) return true; Music_sequence* alt = r->alternative_p_; - Moment stop_mom = now_moment () + r->repeat_p_->duration (); + Moment stop_mom = now_mom () + r->repeat_p_->length_mom (); for (PCursor i (alt->music_p_list_p_->top ()); i.ok () && (i != alt->music_p_list_p_->bottom ()); i++) { - stop_mom += i->duration (); + stop_mom += i->length_mom (); if (dynamic_cast (alt)) break; } - Moment alt_mom = now_moment () + r->repeat_p_->duration (); + Moment alt_mom = now_mom () + r->repeat_p_->length_mom (); /* TODO: figure out what we don't want. @@ -63,9 +63,9 @@ Repeat_engraver::do_try_music (Music* m) { alternative_music_arr_.push (i.ptr ()); alternative_start_mom_arr_.push (alt_mom); - alternative_stop_mom_arr_.push (alt_mom + i->duration ()); + alternative_stop_mom_arr_.push (alt_mom + i->length_mom ()); if (!dynamic_cast (alt)) - alt_mom += i->duration (); + alt_mom += i->length_mom (); } return true; } @@ -75,7 +75,7 @@ Repeat_engraver::do_try_music (Music* m) void Repeat_engraver::acknowledge_element (Score_element_info i) { - Moment now = now_moment (); + Moment now = now_mom (); if (Note_column *c = dynamic_cast (i.elem_l_)) { for (int i = 0; i < volta_p_arr_.size (); i++) @@ -101,7 +101,7 @@ Repeat_engraver::do_removal_processing () void Repeat_engraver::do_process_requests () { - Moment now = now_moment (); + Moment now = now_mom (); Bar_engraver* bar_engraver_l = dynamic_cast (daddy_grav_l ()->get_simple_translator ("Bar_engraver")); for (int i = bar_b_arr_.size (); i < repeated_music_arr_.size (); i++) @@ -137,7 +137,7 @@ Repeat_engraver::do_process_requests () void Repeat_engraver::do_pre_move_processing () { - Moment now = now_moment (); + Moment now = now_mom (); for (int i = bar_b_arr_.size (); i--; ) { if (bar_b_arr_[i]) @@ -170,7 +170,7 @@ Repeat_engraver::do_post_move_processing () { #if 0 Time_description const *time = get_staff_info().time_C_; - Moment now = now_moment (); + Moment now = now_mom (); for (int i = volta_p_arr_.size (); i--; ) { if ((now > alternative_stop_mom_arr_[i]) diff --git a/lily/repeated-music-iterator.cc b/lily/repeated-music-iterator.cc index 8c6982ce7b..31d77da08e 100644 --- a/lily/repeated-music-iterator.cc +++ b/lily/repeated-music-iterator.cc @@ -72,10 +72,10 @@ Repeated_music_iterator::next_moment () const else if (alternative_iter_p_) return alternative_iter_p_->next_moment () + here_mom_; // huh? -// return repeated_music_l ()->repeat_p_->duration () +// return repeated_music_l ()->repeat_p_->length_mom () // * Moment (repeated_music_l ()->repeats_i_) -// + repeated_music_l ()->alternative_p_->duration () + here_mom_; - return repeated_music_l ()->alternative_p_->duration () + here_mom_; +// + repeated_music_l ()->alternative_p_->length_mom () + here_mom_; + return repeated_music_l ()->alternative_p_->length_mom () + here_mom_; } bool @@ -112,7 +112,7 @@ Repeated_music_iterator::start_next_element () repeat_iter_p_ = 0; alternative_iter_p_ = dynamic_cast (get_iterator_p ((Music*)repeated_music_l ()->alternative_p_)); - here_mom_ += repeated_music_l ()->repeat_p_->duration (); + here_mom_ += repeated_music_l ()->repeat_p_->length_mom (); } else if (alternative_iter_p_) { @@ -128,7 +128,7 @@ Repeated_music_iterator::start_next_element () unfold_i_--; repeat_iter_p_ = get_iterator_p (repeated_music_l ()->repeat_p_); // urg, assume same length alternatives for now... -// here_mom_ += repeated_music_l ()->alternative_p_->music_p_list_p_->top ()->duration (); +// here_mom_ += repeated_music_l ()->alternative_p_->music_p_list_p_->top ()->length_mom (); /* URG this is *wrong* but at least it doesn't dump core @@ -137,7 +137,7 @@ Repeated_music_iterator::start_next_element () how to intercept this... */ - here_mom_ += repeated_music_l ()->alternative_p_->duration (); + here_mom_ += repeated_music_l ()->alternative_p_->length_mom (); } } } diff --git a/lily/repeated-music.cc b/lily/repeated-music.cc index 1bbd2be8c2..e34a5c8da6 100644 --- a/lily/repeated-music.cc +++ b/lily/repeated-music.cc @@ -51,13 +51,13 @@ Repeated_music::transpose (Musical_pitch p) } Moment -Repeated_music::duration () const +Repeated_music::length_mom () const { Moment m; if (repeat_p_) - m += repeat_p_->duration (); + m += repeat_p_->length_mom (); if (alternative_p_) - m += alternative_p_->duration (); + m += alternative_p_->length_mom (); return m; } diff --git a/lily/request-iterator.cc b/lily/request-iterator.cc index 410a38d37c..b2f8a712a4 100644 --- a/lily/request-iterator.cc +++ b/lily/request-iterator.cc @@ -17,7 +17,7 @@ void Request_chord_iterator::construct_children() { - elt_duration_ =elt_l ()->duration (); + elt_length_mom_ =elt_l ()->length_mom (); get_req_translator_l(); } @@ -36,7 +36,7 @@ Request_chord_iterator::Request_chord_iterator () bool Request_chord_iterator::ok() const { - return (elt_duration_ && !last_b_) || first_b_; + return (elt_length_mom_ && !last_b_) || first_b_; } @@ -46,7 +46,7 @@ Request_chord_iterator::next_moment() const { Moment m (0); if (!first_b_) - m = elt_duration_; + m = elt_length_mom_; return m; } @@ -54,7 +54,7 @@ void Request_chord_iterator::do_print() const { #ifndef NPRINT - DOUT << "duration: " << elt_duration_; + DOUT << "duration: " << elt_length_mom_; #endif } @@ -78,6 +78,6 @@ Request_chord_iterator::do_process_and_next (Moment mom) first_b_ = false; } - if (mom >= elt_duration_) + if (mom >= elt_length_mom_) last_b_ = true; } diff --git a/lily/rhythmic-grouping.cc b/lily/rhythmic-grouping.cc new file mode 100644 index 0000000000..ad2f2b4d13 --- /dev/null +++ b/lily/rhythmic-grouping.cc @@ -0,0 +1,383 @@ +/* + rhythmic-grouping.cc -- implement Rhythmic_grouping + + source file of the GNU LilyPond music typesetter + + (c) 1997--1998 Han-Wen Nienhuys +*/ + +#include "debug.hh" +#include "rhythmic-grouping.hh" +#include "interval.hh" + +void +Rhythmic_grouping::init() +{ + interval_ = 0; + children.clear(); +} + +void +Rhythmic_grouping::OK() const +{ +#ifndef NDEBUG + assert (bool (children.size()) != bool (interval_)); + + for (int i= 0; i < children.size(); i++) + { + children[i]->OK(); + if (i>0) + assert (children[i-1]->interval().right == + children[i]->interval().left); + } +#endif +} + +Moment +Rhythmic_grouping::length_mom () const +{ + return interval().length (); +} + +MInterval +Rhythmic_grouping::interval() const +{ + if (interval_) + return *interval_; + else + return + MInterval (children[0]->interval().left, + children.top()->interval ().right); +} + +void +Rhythmic_grouping::split (Rhythmic_grouping r) +{ + if (interval_) + return ; + + r.intersect (interval()); + split (r.intervals()); + + for (int i= 0; i < children.size(); i++) + { + if (!children[i]->interval_) + { + Rhythmic_grouping here (r); + children[i]->split (here); + } + } +} + + +Array +Rhythmic_grouping::intervals() +{ + Array r; + if (interval_ || children.size() == 1) + { + MInterval i (interval()); + MInterval r1(i), r2(i); + r1.right = r2.left = i.center(); + r.push (r1); r.push (r2); + } + else + { + for (int i=0; i < children.size(); i++) + r.push (children[i]->interval()); + } + return r; +} + +void +Rhythmic_grouping::intersect (MInterval t) +{ + if (interval_) + { + interval_->intersect (t); + return; + } + + for (int i=0; i < children.size(); i++) + { + MInterval inter = intersection (t, children[i]->interval()); + if (inter.empty_b() || inter.length () <= Moment (0)) + { + delete children[i]; + children[i] =0; + } + else + { + children[i]->intersect (t); + } + } + for (int i=0; i < children.size();) + { + if (!children[i]) + children.del (i); + else + i++; + } + +} + +/** + Put our children in branches of #this#. + The min and max time intervals coincide with elements of #splitpoints# + + I really should be documenting what is happening here, but I find + that difficult, since I don't really understand what's going on here. + + */ +void +Rhythmic_grouping::split (Array splitpoints) +{ + //check on splitpoints.. + int j = 0, i = 0, starti = 0, startj = 0; + + Array ch; + while (1) + { + if (i >= children.size() || j >= splitpoints.size ()) + break; + + assert ( + children[starti]->interval().left== splitpoints[startj].left); + if (children[i]->interval().right < splitpoints[j].right) + { + i ++; + } + else if (children[i]->interval().right > splitpoints[j].right) + { + j ++; + } + else + { + + if (i == starti) + { + ch.push (children[i]); + } + else + { + Rhythmic_grouping *newchild=new Rhythmic_grouping ( + children.slice (starti, i+1)); + + ch.push (newchild); + } + i ++; + j++; + starti = i; + startj = j; + + + } + } + if (ch.size() != 1) + children = ch; +} + + +Rhythmic_grouping::Rhythmic_grouping (MInterval t, int n) +{ + init(); + if (n == 1 || !n) + { + interval_ = new MInterval (t); + return; + } + Moment dt = t.length ()/Moment (n); + MInterval basic = MInterval (t.left, t.left+dt); + for (int i= 0; i < n; i++) + children.push (new Rhythmic_grouping (dt*Moment (i) + basic)); +} + + +Rhythmic_grouping::Rhythmic_grouping (Array r) + :children (r) +{ + interval_ =0; +} + +Rhythmic_grouping::~Rhythmic_grouping() +{ + junk(); +} + +void +Rhythmic_grouping::copy (Rhythmic_grouping const&s) +{ + interval_ = (s.interval_)? new MInterval (*s.interval_) : 0; + for (int i=0; i < s.children.size(); i++) + children.push (new Rhythmic_grouping (*s.children[i])); +} + +void +Rhythmic_grouping::operator=(Rhythmic_grouping const &s) +{ + junk(); + copy (s); +} + +Rhythmic_grouping::Rhythmic_grouping (Rhythmic_grouping const&s) +{ + init(); + copy (s); +} + +void +Rhythmic_grouping::junk() +{ + delete interval_; + for (int i=0; i < children.size(); i++) + delete children[i]; + init(); +} + +void +Rhythmic_grouping::print() const +{ +#ifndef NPRINT + DOUT << "{ \n"; + if (interval_) + DOUT <<" Interval "<< interval_->str(); + for (int i=0; i < children.size(); i++) + { + children[i]->print(); + } + DOUT << "}\n"; +#endif +} + +bool +Rhythmic_grouping::child_fit_b (Moment start) +{ + if (children.size()) + return (children.top()->interval ().right== start); + + return true; +} + +void +Rhythmic_grouping::add_child (Moment start, Moment len) +{ + Moment stop = start+len; + assert (child_fit_b (start)); + children.push (new Rhythmic_grouping (MInterval (start, stop))); +} + +Rhythmic_grouping::Rhythmic_grouping() +{ + interval_ =0; +} + +int +min_elt (Array v) +{ + int i = 1000; // ugh + for (int j = 0 ; j < v.size(); j++) + i = i +Rhythmic_grouping::generate_beams (Array flags, int &flagidx) +{ + assert (!interval_) ; + + Array< Array > children_beams; + for (int i=0; i < children.size(); i++) + { + Array child_beams; + if (children[i]->interval_) + { + int f = flags[flagidx++]; + child_beams.push (f); + } + else + { + child_beams = children[i]-> + generate_beams (flags, flagidx); + } + children_beams.push (child_beams); + } + Array beams; + int lastm, m, nextm; + for (int i=0; i < children_beams.size(); i++) + { + bool add_left = (i >0); + bool add_right = (i < children_beams.size() -1); + + if (!i) + m = min_elt (children_beams[i]); + if (add_right) + nextm = min_elt (children_beams[i+1]); + + if (children_beams[i].size() == 1) + { + if (add_right) + beams.push (m); + if (add_left) + beams.push (m); + } + else + { + if (add_left) + beams.push (lastm translate (m); +} + +void +Rhythmic_grouping::extend (MInterval m) const +{ + assert (m.left >= interval().left); + while (m.right >interval().right) + { + Array a (children); + for (int i=0; i < a.size(); i++) + { + a[i] =new Rhythmic_grouping (*children[i]); + a[i]->translate (children.top()->interval ().right); + } + ((Rhythmic_grouping*)this)->children.concat (a); + } + assert (m.right <= interval().right); + OK(); +} + +Rhythmic_grouping +parse_grouping (Array beat_i_arr, Array elt_length_arr) +{ + Moment here =0; + assert (beat_i_arr.size() == elt_length_arr.size ()); + + Array children; + for (int i=0; i < beat_i_arr.size(); i++) + { + Moment last = here; + here += elt_length_arr[i] * Moment (beat_i_arr[i]); + children.push ( + new Rhythmic_grouping (MInterval (last, here), + beat_i_arr[i])); + } + return Rhythmic_grouping (children); +} + diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc index e1ab3ab2fb..c94779bc3a 100644 --- a/lily/score-engraver.cc +++ b/lily/score-engraver.cc @@ -106,7 +106,7 @@ Score_engraver::do_announces() { if (Rhythmic_req *rq = dynamic_cast (announce_info_arr_[i].req_l_)) { - musical_column_l_->add_duration (rq->duration()); + musical_column_l_->add_duration (rq->length_mom ()); } } Engraver_group_engraver::do_announces(); diff --git a/lily/score.cc b/lily/score.cc index 291616b882..4f85afc8ff 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -58,7 +58,7 @@ Score::run_translator (Music_output_def *odef_l) return ; } *mlog << '\n' << _("Interpreting music...") << flush; - trans_p->last_mom_ = music_p_->duration (); + trans_p->last_mom_ = music_p_->length_mom (); Music_iterator * iter = Music_iterator::static_get_iterator_p (music_p_, trans_p); diff --git a/lily/sequential-music-iterator.cc b/lily/sequential-music-iterator.cc index 5ec0a76cd9..d5ba03eef6 100644 --- a/lily/sequential-music-iterator.cc +++ b/lily/sequential-music-iterator.cc @@ -50,7 +50,7 @@ Sequential_music_iterator::leave_element() { delete iter_p_; iter_p_ =0; - Moment elt_time = cursor_p_->ptr()->duration (); + Moment elt_time = cursor_p_->ptr()->length_mom (); here_mom_ += elt_time; cursor_p_->next(); } diff --git a/lily/spring-spacer.cc b/lily/spring-spacer.cc index cbf3f2e7c3..3ca32eba6c 100644 --- a/lily/spring-spacer.cc +++ b/lily/spring-spacer.cc @@ -599,7 +599,7 @@ Spring_spacer::calc_idealspacing() if (delta_t) { Real k= paper_l()->arithmetic_constant (context_shortest_arr[i]); - durational_distance = paper_l()->duration_to_dist (delta_t,k); + durational_distance = paper_l()->length_mom_to_dist (delta_t,k); } symbol_distance += -cols_[i+1].width_[LEFT]; @@ -632,7 +632,7 @@ Spring_spacer::calc_idealspacing() } Moment delta_t = scol_l (i+1)->when() - scol_l (i)->when (); Real k= paper_l()->arithmetic_constant(context_shortest); - Real dist = paper_l()->duration_to_dist (shortest_playing_len, k); + Real dist = paper_l()->length_mom_to_dist (shortest_playing_len, k); dist *= (double)(delta_t / shortest_playing_len); /* diff --git a/lily/staff-margin-engraver.cc b/lily/staff-margin-engraver.cc index 3b1301cbb8..54fe0efa1f 100644 --- a/lily/staff-margin-engraver.cc +++ b/lily/staff-margin-engraver.cc @@ -49,7 +49,7 @@ Staff_margin_engraver::acknowledge_element (Score_element_info i) String long_str = get_property ("instrument", 0); String str = get_property ("instr", 0); - if (now_moment () > Moment (0) && str.length_i ()) + if (now_mom () > Moment (0) && str.length_i ()) long_str = str; if (long_str.empty_b ()) diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index 9a78dd4109..2a8cc741dd 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -36,7 +36,7 @@ Tie_engraver::acknowledge_element (Score_element_info i) if (Note_head *nh = dynamic_cast (i.elem_l_)) { Note_req * m = dynamic_cast (i.req_l_); - now_heads_.push (CHead_melodic_tuple (nh, m, now_moment()+ m->duration ())); + now_heads_.push (CHead_melodic_tuple (nh, m, now_mom()+ m->length_mom ())); } } @@ -45,7 +45,7 @@ Tie_engraver::do_process_requests () { if (req_l_) { - Moment now = now_moment (); + Moment now = now_mom (); Link_array nharr; stopped_heads_.clear (); @@ -116,7 +116,7 @@ void Tie_engraver::do_post_move_processing () { req_l_ =0; - Moment now = now_moment (); + Moment now = now_mom (); while (past_notes_pq_.size () && past_notes_pq_.front ().end_ < now) past_notes_pq_.delmin (); } diff --git a/lily/time-description.cc b/lily/time-description.cc index 22ab2d9acc..cdbc54aebe 100644 --- a/lily/time-description.cc +++ b/lily/time-description.cc @@ -18,7 +18,7 @@ Time_description::str () const s += "at "; s += when_.str (); s +="\ntime_signature " + (whole_per_measure_/one_beat_).str () +":" + - (Rational (Rational (1)/one_beat_)).str (); + (Moment (Moment (1)/one_beat_)).str (); s += "\nposition " + to_str (bars_i_) + ":"+ whole_in_measure_.str () +"\n}\n"; return s; } @@ -69,7 +69,7 @@ Time_description::Time_description() void Time_description::add (Moment dt) { - assert (dt >= Rational (0)); + assert (dt >= Moment (0)); when_ += dt; whole_in_measure_ += dt; @@ -84,7 +84,7 @@ void Time_description::set_time_signature (int l, int o) { assert (o); - one_beat_ = Rational (1)/Moment (o); + one_beat_ = Moment (1)/Moment (o); whole_per_measure_ = Moment (l) * one_beat_; } @@ -102,7 +102,7 @@ Time_description::allow_time_signature_change_b() String Time_description::try_set_partial_str (Moment p) const { - if (p whole_per_measure_) return (_ ("partial measure too large")); diff --git a/lily/timing-translator.cc b/lily/timing-translator.cc index 8e8d58a76d..26e2f21dec 100644 --- a/lily/timing-translator.cc +++ b/lily/timing-translator.cc @@ -74,7 +74,7 @@ Timing_translator::do_process_requests() } else if (Partial_measure_req *pm = dynamic_cast (tr_l)) { - Moment m = pm->duration_; + Moment m = pm->length_mom_; String error = time_.try_set_partial_str (m); if (error.length_i ()) { @@ -131,13 +131,13 @@ ADD_THIS_TRANSLATOR(Timing_translator); void Timing_translator::do_creation_processing() { - time_.when_ = now_moment (); + time_.when_ = now_mom (); } void Timing_translator::do_post_move_processing() { - time_.add (now_moment () - time_.when_); + time_.add (now_mom () - time_.when_); } void diff --git a/lily/translator-group.cc b/lily/translator-group.cc index b378cad83a..49cf960b39 100644 --- a/lily/translator-group.cc +++ b/lily/translator-group.cc @@ -245,7 +245,7 @@ Translator_group::nongroup_l_arr () const void Translator_group::terminate_translator (Translator*r_l) { - DOUT << "Removing " << classname (r_l) << " at " << now_moment () << '\n'; + DOUT << "Removing " << classname (r_l) << " at " << now_mom () << '\n'; r_l->removal_processing(); Translator * trans_p =remove_translator_p (r_l); diff --git a/lily/translator.cc b/lily/translator.cc index 30205ed7fd..2e20760894 100644 --- a/lily/translator.cc +++ b/lily/translator.cc @@ -47,9 +47,9 @@ Translator::do_try_music (Music *) Moment -Translator::now_moment () const +Translator::now_mom () const { - return daddy_trans_l_->now_moment (); + return daddy_trans_l_->now_mom (); } diff --git a/lily/tuplet-engraver.cc b/lily/tuplet-engraver.cc index 5bcfa0aa56..b751d5eae7 100644 --- a/lily/tuplet-engraver.cc +++ b/lily/tuplet-engraver.cc @@ -25,7 +25,7 @@ Tuplet_engraver::do_try_music (Music *r) if (!dynamic_cast (el)) { compressed_music_arr_.push (c); - stop_moments_.push (now_moment () + c->duration ()); + stop_moments_.push (now_mom () + c->length_mom ()); } return true; } @@ -66,7 +66,7 @@ Tuplet_engraver::acknowledge_element (Score_element_info i) void Tuplet_engraver::do_post_move_processing () { - Moment now = now_moment (); + Moment now = now_mom (); for (int i= started_span_p_arr_.size (); i--; ) { if (now >= stop_moments_[i]) -- 2.39.5