]> git.donarmstrong.com Git - lilypond.git/blob - lib/include/duration-convert.hh
release: 1.3.0
[lilypond.git] / lib / 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--1999 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 const midi_as_plet_b_s;
33   static bool no_quantify_b_s;
34   static bool no_double_dots_b_s;
35   static bool no_triplets_b_s;
36   static int no_smaller_than_i_s;
37   static Array<Duration> dur_array_s;
38
39   /// Return number of ticks in (ticks, division_1) representation
40   static int dur2ticks_i (Duration dur );
41         
42   /// Return the type_i representation of note length i
43   static int i2_type (int i);
44
45   /// Return the note length corresponding to the type_i representation
46   /// Return 0 if longer than whole note.
47   static int type2_i (int type);
48
49   /// Return Rational representation (fraction of whole note).
50   static Rational dur2_mom (Duration dur );
51
52   /// Return Mudela string representation.
53   static String dur2_str (Duration dur );
54
55   /// Return duration from Rational (fraction of whole) representation.
56   static Duration mom2_dur (Rational mom );
57
58   /// Return standardised duration, best guess if not exact.
59   static Duration mom2standardised_dur (Rational mom );
60   
61   /// Return plet factor (not a Rational: should use Rational?).
62   static Rational plet_factor_mom (Duration dur );
63
64   static void set_array ();
65
66   /** Return synchronisation factor for mom, so that
67       mom2_dur (mom / sync_f ) will return the duration dur.            
68   */ 
69   static Real sync_f (Duration dur, Rational mom );
70
71   /// Return exact duration, in midi-ticks if not-exact.
72   static Duration ticks2_dur (int ticks_i );
73
74   /// Return standardised duration, best guess if not exact.
75   static Duration ticks2standardised_dur (int ticks_i );
76 };
77
78
79 #endif // DURATION_CONVERT_HH