]> git.donarmstrong.com Git - lilypond.git/blob - midi2ly/include/duration-convert.hh
patch::: 1.5.18.moh1: [PATCH] 1.4 Lyric alignment
[lilypond.git] / midi2ly / include / duration-convert.hh
1 /*
2   duration-convert.hh -- declare Duration_convert
3
4   source file of the LilyPond music typesetter
5
6   (c)  1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9
10 #ifndef DURATION_CONVERT_HH
11 #define DURATION_CONVERT_HH
12 #include "duration.hh"
13 #include "string.hh"
14 #include "array.hh"
15
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 :-).
20
21         A Rational (mom) is a Rational that holds the time fraction 
22         compared to a whole note (before also called wholes).
23
24         [todo]
25         move all statics to real members, instantiate Duration_convert
26         object (s).
27 */
28 struct Duration_convert {
29         
30   /* Urgh. statics.
31    */
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;
37
38   /// Return number of ticks in (ticks, division_1) representation
39   static int dur2ticks_i (Duration dur );
40         
41   /// Return the type_i representation of note length i
42   static int i2_type (int i);
43
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);
47
48   /// Return Rational representation (fraction of whole note).
49   static Rational dur2_mom (Duration dur );
50
51   /// Return Lilypond string representation.
52   static String dur2_str (Duration dur );
53
54   /// Return duration from Rational (fraction of whole) representation.
55   static Duration mom2_dur (Rational mom );
56
57   /// Return standardised duration, best guess if not exact.
58   static Duration mom2standardised_dur (Rational mom );
59   
60   /// Return plet factor (not a Rational: should use Rational?).
61   static Rational plet_factor_mom (Duration dur );
62
63   static void set_array ();
64
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 );
69
70   /// Return exact duration, in midi-ticks if not-exact.
71   static Duration ticks2_dur (int ticks_i );
72
73   /// Return standardised duration, best guess if not exact.
74   static Duration ticks2standardised_dur (int ticks_i );
75 };
76
77
78 #endif // DURATION_CONVERT_HH