2 duration-convert.hh -- declare
4 source file of the LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #ifndef DURATION_CONVERT_HH
11 #define DURATION_CONVERT_HH
12 #include "duration.hh"
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 :-).
22 A Moment (mom) is a Rational that holds the time fraction
23 compared to a whole note (before also called wholes).
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 ().
30 move all statics to real members, instantiate Duration_convert
33 struct Duration_convert {
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;
44 /// Return number of ticks in (ticks, division_1) representation
45 static int dur2ticks_i (Duration dur );
47 /// Return the type_i representation of note length i
48 static int i2_type (int i);
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);
54 /// Return Moment representation (fraction of whole note).
55 static Moment dur2_mom (Duration dur );
57 /// Return Mudela string representation.
58 static String dur2_str (Duration dur );
60 /// Return duration from Moment (fraction of whole) representation.
61 static Duration mom2_dur (Moment mom );
63 /// Return standardised duration, best guess if not exact.
64 static Duration mom2standardised_dur (Moment mom );
66 /// Return plet factor (not a Moment: should use Rational?).
67 static Moment plet_factor_mom (Duration dur );
69 static void set_array ();
71 /** Return synchronisation factor for mom, so that
72 mom2_dur (mom / sync_f ) will return the duration dur.
74 static Real sync_f (Duration dur, Moment mom );
76 /// Return exact duration, in midi-ticks if not-exact.
77 static Duration ticks2_dur (int ticks_i );
79 /// Return standardised duration, best guess if not exact.
80 static Duration ticks2standardised_dur (int ticks_i );
84 #endif // DURATION_CONVERT_HH