]> git.donarmstrong.com Git - lilypond.git/blob - lib/duration.cc
release: 0.1.9
[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 "proto.hh"
11 #include "plist.hh"
12 #include "string.hh"
13 #include "source-file.hh"
14 #include "source.hh"
15 #include "moment.hh"
16 #include "duration.hh"
17 #include "duration-convert.hh"
18
19 // statics Duration
20 int Duration::division_1_i_s = 384 * 4;
21
22
23 Duration::Duration()
24 {
25   durlog_i_ = 0;
26   dots_i_ = 0;
27   ticks_i_ = 0;
28 }
29
30 Duration::Duration( int type_i, int dots_i = 0 )
31 {
32   durlog_i_ = type_i;
33   dots_i_ = dots_i;
34   ticks_i_ = 0;
35 }
36
37 bool
38 Duration::duration_type_b(int t)
39 {
40   /*
41     ugh. Assuming behavior of conversion funcs on broken input.
42    */
43   return t == Duration_convert::type2_i( Duration_convert::i2_type(t));
44 }
45
46 // ugh, what's this?
47 // i should be called "mom()", ... or at least "length_mom()"
48 Moment
49 Duration::length() const
50 {
51   return Duration_convert::dur2_mom(*this);
52 }
53
54 void
55 Duration::set_plet(int i, int t)
56 {
57   plet_.iso_i_ = i; 
58   plet_.type_i_ = t;
59 }
60
61 void
62 Duration::set_plet(Duration d)
63 {
64   plet_.iso_i_ = d.plet_.iso_i_; 
65   plet_.type_i_ = d.plet_.type_i_;
66 }
67
68 void
69 Duration::set_ticks( int ticks_i )
70 {
71   assert( durlog_i_ <10 );
72   assert( !dots_i_ );
73   ticks_i_ = ticks_i;
74 }
75
76 String
77 Duration::str()const
78 {
79   return Duration_convert::dur2_str(*this);
80 }
81
82
83 bool
84 Duration::plet_b()
85 {
86   return !plet_.unit_b();
87 }