3 duration-convert.hh -- declare
5 source file of the LilyPond music typesetter
7 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
11 #ifndef DURATION_CONVERT_HH
12 #define DURATION_CONVERT_HH
13 #include "duration.hh"
17 Duration_convert handles all conversions to -n fro Duration (dur).
18 That is including (integer + division) representation for MIDI,
19 and conversion from unexact time representation (best guess :-).
21 A Moment (mom) is a Rational that holds the time fraction
22 compared to a whole note (before also called wholes).
24 SUGGESTION: currently a moment in time is called moment too;
25 let-s typedef Rational When too, so that we get
26 When Staff_column::when(), Moment Voice_element::mom().
28 struct Duration_convert {
32 static bool be_blonde_b_s; // cute, but not informative. everythiing is blonde, right? HW
33 static bool no_double_dots_b_s;
34 static bool no_triplets_b_s;
35 static int no_smaller_than_i_s;
37 // /// Most used division in MIDI, all fine with me.
38 // static int const division_1_c_i = 384;
40 // /// Return (integer, division) representation.
41 // static int dur2_i( Duration dur, int division_1_i = division_1_c_i );
43 /// Return number of ticks in (ticks, division_1) representation
44 static int dur2ticks_i( Duration dur );
46 /// Return Moment representation (fraction of whole note).
47 static Moment dur2_mom( Duration dur );
49 /// Return Mudela string representation.
50 static String dur2_str( Duration dur );
52 // /// Return Moment from (integer, division) representation.
53 // static Moment i2_mom( int i, int division_1_i = division_1_c_i );
55 // /// Return Moment (fraction of whole) representation, best guess.
56 // static Duration mom2_dur( Moment mom );
58 /// Return plet factor (not a Moment: should use Rational?).
59 static Moment plet_factor_mom( Duration dur );
61 /** Return synchronisation factor for mom, so that
62 mom2_dur( mom / sync_f ) will return the duration dur.
64 static Real sync_f( Duration dur, Moment mom );
66 /// Return exact duration, in midi-ticks if not-exact.
67 static Duration ticks2_dur( int ticks_i );
69 /// Return standardised duration, best guess if not exact.
70 static Duration ticks2standardised_dur( int ticks_i );
74 struct Duration_iterator {
75 /// start at shortest: 128:2/3
78 // **** what about these three here ?
79 /// return forward_dur();
80 Duration operator ++(int);
86 Duration operator ()();
89 /// return current dur
92 /// return dur(), step to next
93 Duration forward_dur();
103 #endif // DURATION_CONVERT_HH