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"
19 Duration_convert handles all conversions to -n fro Duration (dur).
20 That is including (integer + division) representation for MIDI,
21 and conversion from unexact time representation (best guess :-).
23 A Moment (mom) is a Rational that holds the time fraction
24 compared to a whole note (before also called wholes).
26 SUGGESTION: currently a moment in time is called moment too;
27 let-s typedef Rational When too, so that we get
28 When Staff_column::when(), Moment Voice_element::mom().
31 move all statics to real members, instantiate Duration_convert
34 struct Duration_convert {
38 static bool const midi_as_plet_b_s = true;
39 static bool no_quantify_b_s;
40 static bool no_double_dots_b_s;
41 static bool no_triplets_b_s;
42 static int no_smaller_than_i_s;
43 static Array<Duration> dur_array_s;
45 // /// Most used division in MIDI, all fine with me.
46 // static int const division_1_c_i = 384;
48 // /// Return (integer, division) representation.
49 // static int dur2_i( Duration dur, int division_1_i = division_1_c_i );
51 /// Return number of ticks in (ticks, division_1) representation
52 static int dur2ticks_i( Duration dur );
54 /// Return Moment representation (fraction of whole note).
55 static Moment dur2_mom( Duration dur );
57 /// Return Mudela string representation.
58 static String dur2_str( Duration dur );
60 // /// Return Moment from (integer, division) representation.
61 // static Moment i2_mom( int i, int division_1_i = division_1_c_i );
63 // /// Return Moment (fraction of whole) representation, best guess.
64 // static Duration mom2_dur( Moment mom );
66 /// Return duration from Moment (fraction of whole) representation.
67 static Duration mom2_dur( Moment mom );
69 /// Return standardised duration, best guess if not exact.
70 static Duration mom2standardised_dur( Moment mom );
72 /// Return plet factor (not a Moment: should use Rational?).
73 static Moment plet_factor_mom( Duration dur );
75 static void set_array();
77 /** Return synchronisation factor for mom, so that
78 mom2_dur( mom / sync_f ) will return the duration dur.
80 static Real sync_f( Duration dur, Moment mom );
82 /// Return exact duration, in midi-ticks if not-exact.
83 static Duration ticks2_dur( int ticks_i );
85 /// Return standardised duration, best guess if not exact.
86 static Duration ticks2standardised_dur( int ticks_i );
90 struct Duration_iterator {
91 /// start at shortest: 128:2/3
94 // **** what about these three here ?
95 /// return forward_dur();
96 Duration operator ++(int);
102 Duration operator ()();
105 /// return current dur
108 /// return dur(), step to next
109 Duration forward_dur();
115 Duration cursor_dur_;
119 #endif // DURATION_CONVERT_HH