]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/duration.hh
0914e754e3171ae1e28f958d74558159eb4577b2
[lilypond.git] / lily / include / duration.hh
1 /*
2   duration.hh -- declare Duration
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997--2007 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #ifndef DURATION_HH
10 #define DURATION_HH
11
12 #include "moment.hh"
13
14 /**
15    A musical duration.
16 */
17 struct Duration
18 {
19 public:
20
21   Duration ();
22   Duration (int, int);
23   Duration (Rational, bool scale);
24   string to_string () const;
25
26   Duration compressed (Rational) const;
27   Rational get_length () const;
28   Rational factor () const { return factor_; }
29   int duration_log () const;
30   int dot_count () const;
31
32   static int compare (Duration const &, Duration const &);
33
34   DECLARE_SCHEME_CALLBACK (less_p, (SCM a, SCM b));
35   DECLARE_SIMPLE_SMOBS (Duration);
36
37 private:
38   /// Logarithm of the base duration.
39   int durlog_;
40   int dots_;
41
42   Rational factor_;
43 };
44
45 INSTANTIATE_COMPARE (Duration, Duration::compare);
46 DECLARE_UNSMOB (Duration, duration);
47
48 #endif // DURATION_HH
49