2 duration-convert.hh -- declare
4 source file of the LilyPond music typesetter
6 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
10 #ifndef DURATION_CONVERT_HH
11 #define DURATION_CONVERT_HH
12 #include "duration.hh"
18 Duration_convert handles all conversions to -n fro Duration (dur).
19 That is including (integer + division) representation for MIDI,
20 and conversion from unexact time representation (best guess :-).
22 A Moment (mom) is a Rational that holds the time fraction
23 compared to a whole note (before also called wholes).
25 SUGGESTION: currently a moment in time is called moment too;
26 let-s typedef Rational When too, so that we get
27 When Staff_column::when (), Moment Voice_element::mom ().
30 move all statics to real members, instantiate Duration_convert
33 struct Duration_convert {
37 static bool const midi_as_plet_b_s = true;
38 static bool no_quantify_b_s;
39 static bool no_double_dots_b_s;
40 static bool no_triplets_b_s;
41 static int no_smaller_than_i_s;
42 static Array<Duration> dur_array_s;
44 // /// Most used division in MIDI, all fine with me.
45 // static int const division_1_c_i = 384;
47 // /// Return (integer, division) representation.
48 // static int dur2_i (Duration dur, int division_1_i = division_1_c_i );
50 /// Return number of ticks in (ticks, division_1) representation
51 static int dur2ticks_i (Duration dur );
53 /// Return the type_i representation of note length i
54 static int i2_type (int i);
56 /// Return the note length corresponding to the type_i representation
57 /// Return 0 if longer than whole note.
58 static int type2_i (int type);
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 duration from Moment (fraction of whole) representation.
73 static Duration mom2_dur (Moment mom );
75 /// Return standardised duration, best guess if not exact.
76 static Duration mom2standardised_dur (Moment mom );
78 /// Return plet factor (not a Moment: should use Rational?).
79 static Moment plet_factor_mom (Duration dur );
81 static void set_array ();
83 /** Return synchronisation factor for mom, so that
84 mom2_dur (mom / sync_f ) will return the duration dur.
86 static Real sync_f (Duration dur, Moment mom );
88 /// Return exact duration, in midi-ticks if not-exact.
89 static Duration ticks2_dur (int ticks_i );
91 /// Return standardised duration, best guess if not exact.
92 static Duration ticks2standardised_dur (int ticks_i );
96 struct Duration_iterator {
97 /// start at shortest: 128:2/3
100 // **** what about these three here ?
101 /// return forward_dur ();
102 Duration operator ++(int);
108 Duration operator ()();
111 /// return current dur
114 /// return dur (), step to next
115 Duration forward_dur ();
121 Duration cursor_dur_;
125 #endif // DURATION_CONVERT_HH