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
28 // int i_; // balltype -> type!
36 Plet( int replace_i, int type_i );
37 Plet( Plet const& plet_c_r );
40 int iso_i_; // 2/3; 2 is not duration, maar of count!
45 Duration_convert handles all conversions to -n fro Duration (dur).
46 That is including (integer + division) representation for MIDI,
47 and conversion from unexact time representation (best guess :-).
49 A Moment (mom) is a Rational that holds the time fraction
50 compared to a whole note (before also called wholes).
52 SUGGESTION: currently a moment in time is called moment too;
53 let-s typedef Rational When too, so that we get
54 When Staff_column::when(), Moment Voice_element::mom().
56 struct Duration_convert {
57 /// Most used division in MIDI, all fine with me.
58 static int const division_1_c_i = 384;
60 /// Return (integer, division) representation.
61 static int dur2_i( Duration dur, int division_1_i = division_1_c_i );
63 /// Return Moment representation (fraction of whole note).
64 static Moment dur2_mom( Duration dur );
66 /// Return Mudela string representation.
67 static String dur2_str( Duration dur );
69 /// Return Moment from (integer, division) representation.
70 static Moment i2_mom( int i, int division_1_i = division_1_c_i );
72 /// Return Moment (fraction of whole) representation, best guess.
73 static Duration mom2_dur( Moment mom );
75 /// Return plet factor (not a Moment: should use Rational?).
76 static Moment plet_factor_mom( Duration dur );
78 /** Return synchronisation factor for mom, so that
79 mom2_dur( mom / sync_f ) will return the duration dur.
81 static Real sync_f( Duration dur, Moment mom );
85 struct Duration_iterator {
86 /// start at shortest: 128:2/3
89 // **** what about these three here ?
90 /// return forward_dur();
91 Duration operator ++(int);
97 Duration operator ()();
100 /// return current dur
103 /// return dur(), step to next
104 Duration forward_dur();
110 Duration cursor_dur_;
113 #endif // DURATION_HH