]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.44
authorfred <fred>
Sun, 24 Mar 2002 19:36:01 +0000 (19:36 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:36:01 +0000 (19:36 +0000)
lib/include/duration.hh
lily/notehead.cc
lily/stem-beam-reg.cc

index 5c562859548f7c3abe8a84b11aa255982a180c4d..de576e9884d78f275f2a7207e80ae0adff73acb6 100644 (file)
-//
-// duration.hh -- declare Duration, Plet, Duration_convert Duration_iterator
-//
-// copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
+/*
+  duration.hh -- declare Duration Plet
+
+  source file of the LilyPond music typesetter
+
+  (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
+
+*/
 
 // split into 4?
 
 #ifndef DURATION_HH
 #define DURATION_HH
 
+#include "fproto.hh"
+#include "moment.hh"
+
 // ugh, to get me in lily lib
 extern bool no_triplets_bo_g;
 
-/// (dur)
-struct Duration {
-       // actually i hate it when other people use default arguments,
-       // because it makes you easily loose track of what-s really
-       // happening; in the routine-s implementation you-re not aware
-       // of this defaultness (who sets this stupid value?).
-       Duration( int type_i = 1, int dots_i = 0, Plet* plet_p = 0 );
-       Duration( Duration const& dur_c_r );
-       ~Duration();
-
-       Duration const& operator =( Duration const& dur_c_r );
-
-       void set_plet( Plet* plet_l ); // handiger: newt zelf
-       void set_ticks( int ticks_i );
-
-       static int division_1_i_s;
-       int type_i_;
-       int dots_i_;
-       Plet* plet_p_;
-       int ticks_i_;
-};
-
-/// (plet)
+/** (plet)
+  The type and replacement value of a  plet (triplet, quintuplet.) Conceptually the same as a rational, but 4/6 != 2/3 
+ */
 struct Plet {
-       Plet( int replace_i, int type_i );
-       
+    Plet( int replace_i, int type_i );
+    Plet();
+    Moment mom()const;
+    bool unit_b()const;
     int iso_i_;  // 2/3; 2 is not duration, maar of count!
-       int type_i_;
+    int type_i_;
 };
 
 /**
-       Duration_convert handles all conversions to -n fro Duration (dur).
-       That is including (integer + division) representation for MIDI,
-       and conversion from unexact time representation (best guess :-).
-
-       A Moment (mom) is a Rational that holds the time fraction 
-       compared to a whole note (before also called wholes).
-
-       SUGGESTION: currently a moment in time is called moment too;
-       let-s typedef Rational When too, so that we get 
-       When Staff_column::when(), Moment Voice_element::mom().
-*/
-struct Duration_convert {
-       static bool be_blonde_b_s;
-       static bool no_double_dots_b_s;
-       static bool no_triplets_b_s;
-       static int no_smaller_than_i_s;
-
-//     /// Most used division in MIDI, all fine with me.
-//     static int const division_1_c_i = 384;
-
-//     /// Return (integer, division) representation.
-//     static int dur2_i( Duration dur, int division_1_i = division_1_c_i );
-
-       /// Return number of ticks in (ticks, division_1) representation
-       static int dur2ticks_i( Duration dur );
-       
-       /// Return Moment representation (fraction of whole note).
-       static Moment dur2_mom( Duration dur );
-
-       /// Return Mudela string representation.
-       static String dur2_str( Duration dur );
-
-//     /// Return Moment from (integer, division) representation.
-//     static Moment i2_mom( int i, int division_1_i = division_1_c_i );
-
-//     /// Return Moment (fraction of whole) representation, best guess.
-//     static Duration mom2_dur( Moment mom );
-
-       /// Return plet factor (not a Moment: should use Rational?).
-       static Moment plet_factor_mom( Duration dur );
-
-       /** Return synchronisation factor for mom, so that
-           mom2_dur( mom / sync_f ) will return the duration dur.              
-       */ 
-       static Real sync_f( Duration dur, Moment mom );
-
-       /// Return exact duration, in midi-ticks if not-exact.
-       static Duration ticks2_dur( int ticks_i );
-
-       /// Return standardised duration, best guess if not exact.
-       static Duration ticks2standardised_dur( int ticks_i );
-};
-
-/// (iter_dur)
-struct Duration_iterator {
-       /// start at shortest: 128:2/3
-       Duration_iterator();
-
-       // **** what about these three here ?
-       /// return forward_dur();
-       Duration operator ++(int); 
-
-       /// return ok()
-       operator bool(); 
-
-       /// return dur()
-       Duration operator ()(); 
-       // ****
-
-       /// return current dur
-       Duration dur();
-
-       /// return dur(), step to next
-       Duration forward_dur();
-
-       /// durations left?
-       bool ok();
-
-private:
-       Duration cursor_dur_;
+  Class to handle "musical" durations. This means: balltype 1,2,4,etc. and dots.
+   
+  (dur)
+  */
+struct Duration {
+    /* actually i hate it when other people use default arguments,
+       because it makes you easily loose track of what-s really
+       happening; in the routine-s implementation you-re not aware
+       of this defaultness (who sets this stupid value?).*/
+    Duration( int type_i = 1, int dots_i = 0);
+    /// is the "plet factor" of this note != 1 ?
+    bool plet_b();
+    String str()const;
+    void set_plet(int,int );
+    void set_ticks( int ticks_i );
+    Moment length() const ;    // zo naai mij
+    static int division_1_i_s;
+    int type_i_;
+    int dots_i_;
+    Plet plet_;
+    int ticks_i_;
 };
-
 #endif // DURATION_HH
 
index fb0c1166c1dd28a7bb7a1cc6905340420b6c00ae..b1f660ef171cc91afbab9ecd06dc75305632ecd8 100644 (file)
@@ -22,8 +22,8 @@ Notehead::Notehead(int ss)
 void
 Notehead::set_rhythmic(Rhythmic_req*r_req_l)
 {
-    balltype = r_req_l->balltype;
-    dots = r_req_l->dots;
+    balltype = r_req_l->duration_.type_i_;
+    dots = r_req_l->duration_.dots_i_;
 }
     
 void
index de09bb09409386cf3da081dfdd4a33710b21d1c9..ad947d2899f3e7ee24ab8bb1a8acec8324081a31 100644 (file)
@@ -41,7 +41,7 @@ Stem_beam_register::try_request(Request*req_l)
     
     if ( req_l->stem() ) {
        if (current_grouping && !current_grouping->child_fit_query(
-           get_staff_info().time_c_l_->whole_in_measure_))
+           get_staff_info().time_C_->whole_in_measure_))
            return false;
 
        if (stem_req_l_ && Stem_req::compare(*stem_req_l_, *req_l->stem()))
@@ -81,15 +81,15 @@ Stem_beam_register::process_requests()
        stem_p_ = new Stem(4);
        if (current_grouping)
            current_grouping->add_child(
-               get_staff_info().time_c_l_->whole_in_measure_,
+               get_staff_info().time_C_->whole_in_measure_,
                stem_req_l_->duration());
 
-       stem_p_->flag = stem_req_l_->balltype;
+       stem_p_->flag = stem_req_l_->duration_.type_i_;
 
        if (beam_p_) {
-           if (stem_req_l_->balltype<= 4)
+           if (stem_req_l_->duration_.type_i_<= 4)
                warning( "stem doesn't fit in Beam",
-                        stem_req_l_->defined_ch_c_l_);
+                        stem_req_l_->defined_ch_C_);
            else
                beam_p_->add(stem_p_);
            stem_p_->print_flag = false;
@@ -124,9 +124,9 @@ Stem_beam_register::pre_move_processing()
        stem_p_ = 0;
     }
     if (beam_p_ && end_beam_b_) {
-       Rhythmic_grouping const * rg_c_l = get_staff_info().rhythmic_c_l_;
-       rg_c_l->extend(current_grouping->interval());
-       beam_p_->set_grouping(*rg_c_l, *current_grouping);
+       Rhythmic_grouping const * rg_C = get_staff_info().rhythmic_C_;
+       rg_C->extend(current_grouping->interval());
+       beam_p_->set_grouping(*rg_C, *current_grouping);
        typeset_element(beam_p_);
        delete current_grouping;
        current_grouping = 0;
@@ -146,7 +146,7 @@ Stem_beam_register::post_move_processing()
 Stem_beam_register::~Stem_beam_register()
 {
     if (beam_p_)
-       warning("unterminated beam", start_req_l_->defined_ch_c_l_);
+       warning("unterminated beam", start_req_l_->defined_ch_C_);
 }
 
 void