]> git.donarmstrong.com Git - lilypond.git/blob - lib/duration.cc
release: 1.0.15
[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--1998 Jan Nieuwenhuizen <janneke@gnu.org>
7            Han-Wen Nienhuys <hanwen@cs.uu.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 #include "duration-iter.hh"
20
21 // statics Duration
22 int Duration::division_1_i_s = 384 * 4;
23
24
25 Duration::Duration ()
26 {
27   durlog_i_ = 0;
28   dots_i_ = 0;
29   ticks_i_ = 0;
30 }
31
32 bool
33 Duration::duration_type_b (int t)
34 {
35   /*
36     ugh. Assuming behavior of conversion funcs on broken input.
37    */
38   return t == Duration_convert::type2_i (Duration_convert::i2_type (t));
39 }
40
41 void
42 Duration::compress (Moment m)
43 {
44   plet_.iso_i_ *= m.num_i ();
45   plet_.type_i_ *= m.den_i (); 
46 }
47
48 // ugh, what's this?
49 // i should be called "mom ()", ... or at least "length_mom ()"
50 Moment
51 Duration::length () const
52 {
53   return Duration_convert::dur2_mom (*this);
54 }
55
56 void
57 Duration::set_plet (int i, int t)
58 {
59   plet_.iso_i_ = i; 
60   plet_.type_i_ = t;
61 }
62
63 /*
64 void
65 Duration::set_plet (Duration d)
66 {
67   plet_.iso_i_ = d.plet_.iso_i_; 
68   plet_.type_i_ = d.plet_.type_i_;
69 }
70 */
71
72 void
73 Duration::set_ticks (int ticks_i)
74 {
75   assert (durlog_i_ <10);
76   assert (!dots_i_);
77   ticks_i_ = ticks_i;
78 }
79
80 String
81 Duration::str () const
82 {
83   return Duration_convert::dur2_str (*this);
84 }
85
86
87 bool
88 Duration::plet_b ()
89 {
90   return !plet_.unit_b ();
91 }
92