2 // duration.hh -- declare Duration, Plet, Duration_convert Duration_iterator
4 // copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
13 // actually i hate it when other people use default arguments,
14 // because it makes you easily loose track of what-s really
15 // happening; in the routine-s implementation you-re not aware
16 // of this defaultness (who sets this stupid value?).
17 Duration( int type_i = 1, int dots_i = 0, Plet* plet_p = 0 );
18 Duration( Duration const& dur_c_r );
21 Duration const& operator =( Duration const& dur_c_r );
23 void set_plet( Plet* plet_l ); // handiger: newt zelf
25 // int i_; // balltype -> type!
33 Plet( int replace_i, int type_i );
34 Plet( Plet const& plet_c_r );
37 int iso_i_; // 2/3; 2 is not duration, maar of count!
42 Duration_convert handles all conversions to -n fro Duration (dur).
43 That is including (integer + division) representation for MIDI,
44 and conversion from unexact time representation (best guess :-).
46 A Moment (mom) is a Rational that holds the time fraction
47 compared to a whole note (before also called wholes).
49 SUGGESTION: currently a moment in time is called moment too;
50 let-s typedef Rational When too, so that we get
51 When Staff_column::when(), Moment Voice_element::mom().
53 struct Duration_convert {
54 /// Most used division in MIDI, all fine with me.
55 static int const division_1_c_i = 384;
57 /// Return (integer, division) representation.
58 static int dur2_i( Duration dur, int division_1_i = division_1_c_i );
60 /// Return Moment representation (fraction of whole note).
61 static Moment dur2_mom( Duration dur );
63 /// Return Mudela string representation.
64 static String dur2_str( Duration dur );
66 /// Return Moment from (integer, division) representation.
67 static Moment i2_mom( int i, int division_1_i = division_1_c_i );
69 /// Return Moment (fraction of whole) representation, best guess.
70 static Duration mom2_dur( Moment mom );
72 /// Return plet factor (not a Moment: should use Rational?).
73 static Moment plet_factor_mom( Duration dur );
75 /** Return synchronisation factor for mom, so that
76 mom2_dur( mom / sync_f ) will return the duration dur.
78 static Real sync_f( Duration dur, Moment mom );
82 struct Duration_iterator {
83 /// start at shortest: 128:2/3
86 // **** what about these three here ?
87 /// return forward_dur();
88 Duration operator ++(int);
94 Duration operator ()();
97 /// return current dur
100 /// return dur(), step to next
101 Duration forward_dur();
107 Duration cursor_dur_;
110 #endif // DURATION_HH