]> git.donarmstrong.com Git - lilypond.git/blob - lib/include/duration-convert.hh
fc7ee51d970b69a30e9a4b67cc083e93ba5cc563
[lilypond.git] / lib / include / duration-convert.hh
1 /*
2           duration-convert.hh -- declare 
3
4   source file of the LilyPond music typesetter
5
6   (c)  1997--1998 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 #include "array.hh"
16
17 /**
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 :-).
21
22         A Moment (mom) is a Rational that holds the time fraction 
23         compared to a whole note (before also called wholes).
24
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 ().
28
29         [todo]
30         move all statics to real members, instantiate Duration_convert
31         object (s).
32 */
33 struct Duration_convert {
34         
35   /* Urgh. statics.
36    */
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;
43
44   /// Return number of ticks in (ticks, division_1) representation
45   static int dur2ticks_i (Duration dur );
46         
47   /// Return the type_i representation of note length i
48   static int i2_type (int i);
49
50   /// Return the note length corresponding to the type_i representation
51   /// Return 0 if longer than whole note.
52   static int type2_i (int type);
53
54   /// Return Moment representation (fraction of whole note).
55   static Moment dur2_mom (Duration dur );
56
57   /// Return Mudela string representation.
58   static String dur2_str (Duration dur );
59
60   /// Return duration from Moment (fraction of whole) representation.
61   static Duration mom2_dur (Moment mom );
62
63   /// Return standardised duration, best guess if not exact.
64   static Duration mom2standardised_dur (Moment mom );
65   
66   /// Return plet factor (not a Moment: should use Rational?).
67   static Moment plet_factor_mom (Duration dur );
68
69   static void set_array ();
70
71   /** Return synchronisation factor for mom, so that
72       mom2_dur (mom / sync_f ) will return the duration dur.            
73   */ 
74   static Real sync_f (Duration dur, Moment mom );
75
76   /// Return exact duration, in midi-ticks if not-exact.
77   static Duration ticks2_dur (int ticks_i );
78
79   /// Return standardised duration, best guess if not exact.
80   static Duration ticks2standardised_dur (int ticks_i );
81 };
82
83
84 #endif // DURATION_CONVERT_HH