]> git.donarmstrong.com Git - lilypond.git/blob - lib/duration.cc
patch::: 0.1.9.jcn3: pats
[lilypond.git] / lib / duration.cc
1 /*
2   duration.cc -- implement Duration, Plet, 
3
4   source file of the LilyPond music typesetter
5
6   (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
7            Han-Wen Nienhuys <hanwen@stack.nl>
8 */
9
10 #include <assert.h>
11 #include "proto.hh"
12 #include "plist.hh"
13 #include "string.hh"
14 #include "source-file.hh"
15 #include "source.hh"
16 #include "moment.hh"
17 #include "duration.hh"
18 #include "duration-convert.hh"
19
20 // statics Duration
21 int Duration::division_1_i_s = 384 * 4;
22
23
24 Duration::Duration()
25 {
26   durlog_i_ = 0;
27   dots_i_ = 0;
28   ticks_i_ = 0;
29 }
30
31 bool
32 Duration::duration_type_b(int t)
33 {
34   /*
35     ugh. Assuming behavior of conversion funcs on broken input.
36    */
37   return t == Duration_convert::type2_i( Duration_convert::i2_type(t));
38 }
39
40 // ugh, what's this?
41 // i should be called "mom()", ... or at least "length_mom()"
42 Moment
43 Duration::length() const
44 {
45   return Duration_convert::dur2_mom(*this);
46 }
47
48 void
49 Duration::set_plet(int i, int t)
50 {
51   plet_.iso_i_ = i; 
52   plet_.type_i_ = t;
53 }
54
55 void
56 Duration::set_plet(Duration d)
57 {
58   plet_.iso_i_ = d.plet_.iso_i_; 
59   plet_.type_i_ = d.plet_.type_i_;
60 }
61
62 void
63 Duration::set_ticks( int ticks_i )
64 {
65   assert( durlog_i_ <10 );
66   assert( !dots_i_ );
67   ticks_i_ = ticks_i;
68 }
69
70 String
71 Duration::str()const
72 {
73   return Duration_convert::dur2_str(*this);
74 }
75
76
77 bool
78 Duration::plet_b()
79 {
80   return !plet_.unit_b();
81 }