3 duration-convert.hh -- declare
5 source file of the LilyPond music typesetter
7 (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
11 #ifndef DURATION_CONVERT_HH
12 #define DURATION_CONVERT_HH
13 #include "duration.hh"
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 Moment (mom) is a Rational that holds the time fraction
22 compared to a whole note (before also called wholes).
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().
28 struct Duration_convert {
32 static bool const midi_as_plet_b_s = true;
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;
38 // /// Most used division in MIDI, all fine with me.
39 // static int const division_1_c_i = 384;
41 // /// Return (integer, division) representation.
42 // static int dur2_i( Duration dur, int division_1_i = division_1_c_i );
44 /// Return number of ticks in (ticks, division_1) representation
45 static int dur2ticks_i( Duration dur );
47 /// Return Moment representation (fraction of whole note).
48 static Moment dur2_mom( Duration dur );
50 /// Return Mudela string representation.
51 static String dur2_str( Duration dur );
53 // /// Return Moment from (integer, division) representation.
54 // static Moment i2_mom( int i, int division_1_i = division_1_c_i );
56 // /// Return Moment (fraction of whole) representation, best guess.
57 // static Duration mom2_dur( Moment mom );
59 /// Return duration from Moment (fraction of whole) representation.
60 static Duration mom2_dur( Moment mom );
62 /// Return standardised duration, best guess if not exact.
63 static Duration mom2standardised_dur( Moment mom );
65 /// Return plet factor (not a Moment: should use Rational?).
66 static Moment plet_factor_mom( Duration dur );
68 /** Return synchronisation factor for mom, so that
69 mom2_dur( mom / sync_f ) will return the duration dur.
71 static Real sync_f( Duration dur, Moment mom );
73 /// Return exact duration, in midi-ticks if not-exact.
74 static Duration ticks2_dur( int ticks_i );
76 /// Return standardised duration, best guess if not exact.
77 static Duration ticks2standardised_dur( int ticks_i );
81 struct Duration_iterator {
82 /// start at shortest: 128:2/3
85 // **** what about these three here ?
86 /// return forward_dur();
87 Duration operator ++(int);
93 Duration operator ()();
96 /// return current dur
99 /// return dur(), step to next
100 Duration forward_dur();
106 Duration cursor_dur_;
110 #endif // DURATION_CONVERT_HH