lilypond-1.3.141
[lilypond.git] / midi2ly / include / duration-convert.hh
blobdb6818e2f242e35852cfa6b0db120513a0b60741
1 /*
2 duration-convert.hh -- declare Duration_convert
4 source file of the LilyPond music typesetter
6 (c) 1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
10 #ifndef DURATION_CONVERT_HH
11 #define DURATION_CONVERT_HH
12 #include "duration.hh"
13 #include "string.hh"
14 #include "array.hh"
16 /**
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 Rational (mom) is a Rational that holds the time fraction
22 compared to a whole note (before also called wholes).
24 [todo]
25 move all statics to real members, instantiate Duration_convert
26 object (s).
28 struct Duration_convert {
30 /* Urgh. statics.
32 static bool no_quantify_b_s;
33 static bool no_double_dots_b_s;
34 static bool no_tuplets_b_s;
35 static int no_smaller_than_i_s;
36 static Array<Duration> dur_array_s;
38 /// Return number of ticks in (ticks, division_1) representation
39 static int dur2ticks_i (Duration dur );
41 /// Return the type_i representation of note length i
42 static int i2_type (int i);
44 /// Return the note length corresponding to the type_i representation
45 /// Return 0 if longer than whole note.
46 static int type2_i (int type);
48 /// Return Rational representation (fraction of whole note).
49 static Rational dur2_mom (Duration dur );
51 /// Return Lilypond string representation.
52 static String dur2_str (Duration dur );
54 /// Return duration from Rational (fraction of whole) representation.
55 static Duration mom2_dur (Rational mom );
57 /// Return standardised duration, best guess if not exact.
58 static Duration mom2standardised_dur (Rational mom );
60 /// Return plet factor (not a Rational: should use Rational?).
61 static Rational plet_factor_mom (Duration dur );
63 static void set_array ();
65 /** Return synchronisation factor for mom, so that
66 mom2_dur (mom / sync_f ) will return the duration dur.
67 */
68 static Real sync_f (Duration dur, Rational mom );
70 /// Return exact duration, in midi-ticks if not-exact.
71 static Duration ticks2_dur (int ticks_i );
73 /// Return standardised duration, best guess if not exact.
74 static Duration ticks2standardised_dur (int ticks_i );
78 #endif // DURATION_CONVERT_HH