2 // duration.hh -- declare Duration, Plet, Duration_convert Duration_iterator
4 // copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
11 // ugh, to get me in lily lib
12 extern bool no_triplets_bo_g;
16 // actually i hate it when other people use default arguments,
17 // because it makes you easily loose track of what-s really
18 // happening; in the routine-s implementation you-re not aware
19 // of this defaultness (who sets this stupid value?).
20 Duration( int type_i = 1, int dots_i = 0, Plet* plet_p = 0 );
21 Duration( Duration const& dur_c_r );
24 Duration const& operator =( Duration const& dur_c_r );
26 void set_plet( Plet* plet_l ); // handiger: newt zelf
27 void set_ticks( int ticks_i );
29 static int division_1_i_s;
30 // int i_; // balltype -> type!
39 Plet( int replace_i, int type_i );
40 Plet( Plet const& plet_c_r );
43 int iso_i_; // 2/3; 2 is not duration, maar of count!
48 Duration_convert handles all conversions to -n fro Duration (dur).
49 That is including (integer + division) representation for MIDI,
50 and conversion from unexact time representation (best guess :-).
52 A Moment (mom) is a Rational that holds the time fraction
53 compared to a whole note (before also called wholes).
55 SUGGESTION: currently a moment in time is called moment too;
56 let-s typedef Rational When too, so that we get
57 When Staff_column::when(), Moment Voice_element::mom().
59 struct Duration_convert {
60 static bool be_blonde_b_s;
61 static bool no_double_dots_b_s;
62 static bool no_triplets_b_s;
63 static int no_smaller_than_i_s;
65 // /// Most used division in MIDI, all fine with me.
66 // static int const division_1_c_i = 384;
68 // /// Return (integer, division) representation.
69 // static int dur2_i( Duration dur, int division_1_i = division_1_c_i );
71 /// Return number of ticks in (ticks, division_1) representation
72 static int dur2ticks_i( Duration dur );
74 /// Return Moment representation (fraction of whole note).
75 static Moment dur2_mom( Duration dur );
77 /// Return Mudela string representation.
78 static String dur2_str( Duration dur );
80 // /// Return Moment from (integer, division) representation.
81 // static Moment i2_mom( int i, int division_1_i = division_1_c_i );
83 // /// Return Moment (fraction of whole) representation, best guess.
84 // static Duration mom2_dur( Moment mom );
86 /// Return plet factor (not a Moment: should use Rational?).
87 static Moment plet_factor_mom( Duration dur );
89 /** Return synchronisation factor for mom, so that
90 mom2_dur( mom / sync_f ) will return the duration dur.
92 static Real sync_f( Duration dur, Moment mom );
94 /// Return exact duration, in midi-ticks if not-exact.
95 static Duration ticks2_dur( int ticks_i );
97 /// Return standardised duration, best guess if not exact.
98 static Duration ticks2standardised_dur( int ticks_i );
102 struct Duration_iterator {
103 /// start at shortest: 128:2/3
106 // **** what about these three here ?
107 /// return forward_dur();
108 Duration operator ++(int);
114 Duration operator ()();
117 /// return current dur
120 /// return dur(), step to next
121 Duration forward_dur();
127 Duration cursor_dur_;
130 #endif // DURATION_HH