]> git.donarmstrong.com Git - lilypond.git/blob - lib/include/duration-convert.hh
release: 0.0.44
[lilypond.git] / lib / include / duration-convert.hh
1
2 /*
3           duration-convert.hh -- declare 
4
5   source file of the LilyPond music typesetter
6
7   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
8 */
9
10
11 #ifndef DURATION_CONVERT_HH
12 #define DURATION_CONVERT_HH
13 #include "duration.hh"
14 #include "string.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 Moment (mom) is a Rational that holds the time fraction 
22         compared to a whole note (before also called wholes).
23
24         SUGGESTION: currently a moment in time is called moment too;
25         let-s typedef Rational When too, so that we get 
26         When Staff_column::when(), Moment Voice_element::mom().
27 */
28 struct Duration_convert {
29         
30     /* Urgh. statics.
31      */
32     static bool be_blonde_b_s;  // cute, but not informative. everythiing is blonde, right? HW
33     static bool no_double_dots_b_s;
34     static bool no_triplets_b_s;
35     static int no_smaller_than_i_s;
36
37 //      /// Most used division in MIDI, all fine with me.
38 //      static int const division_1_c_i = 384;
39
40 //      /// Return (integer, division) representation.
41 //      static int dur2_i( Duration dur, int division_1_i = division_1_c_i );
42
43     /// Return number of ticks in (ticks, division_1) representation
44     static int dur2ticks_i( Duration dur );
45         
46     /// Return Moment representation (fraction of whole note).
47     static Moment dur2_mom( Duration dur );
48
49     /// Return Mudela string representation.
50     static String dur2_str( Duration dur );
51
52 //      /// Return Moment from (integer, division) representation.
53 //      static Moment i2_mom( int i, int division_1_i = division_1_c_i );
54
55 //      /// Return Moment (fraction of whole) representation, best guess.
56 //      static Duration mom2_dur( Moment mom );
57
58     /// Return plet factor (not a Moment: should use Rational?).
59     static Moment plet_factor_mom( Duration dur );
60
61     /** Return synchronisation factor for mom, so that
62       mom2_dur( mom / sync_f ) will return the duration dur.            
63       */ 
64     static Real sync_f( Duration dur, Moment mom );
65
66     /// Return exact duration, in midi-ticks if not-exact.
67     static Duration ticks2_dur( int ticks_i );
68
69     /// Return standardised duration, best guess if not exact.
70     static Duration ticks2standardised_dur( int ticks_i );
71 };
72
73 /// (iter_dur)
74 struct Duration_iterator {
75     /// start at shortest: 128:2/3
76     Duration_iterator();
77
78     // **** what about these three here ?
79     /// return forward_dur();
80     Duration operator ++(int); 
81
82     /// return ok()
83     operator bool(); 
84
85     /// return dur()
86     Duration operator ()(); 
87     // ****
88
89     /// return current dur
90     Duration dur();
91
92     /// return dur(), step to next
93     Duration forward_dur();
94
95     /// durations left?
96     bool ok();
97
98 private:
99     Duration cursor_dur_;
100 };
101
102
103 #endif // DURATION_CONVERT_HH