]> git.donarmstrong.com Git - lilypond.git/blob - lib/duration.cc
7bdf8d00dccf0822f3b7bec7d4ea266124099ca7
[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 // ugh, what's this?
42 // i should be called "mom ()", ... or at least "length_mom ()"
43 Moment
44 Duration::length () const
45 {
46   return Duration_convert::dur2_mom (*this);
47 }
48
49 void
50 Duration::set_plet (int i, int t)
51 {
52   plet_.iso_i_ = i; 
53   plet_.type_i_ = t;
54 }
55
56 /*
57 void
58 Duration::set_plet (Duration d)
59 {
60   plet_.iso_i_ = d.plet_.iso_i_; 
61   plet_.type_i_ = d.plet_.type_i_;
62 }
63 */
64
65 void
66 Duration::set_ticks (int ticks_i)
67 {
68   assert (durlog_i_ <10);
69   assert (!dots_i_);
70   ticks_i_ = ticks_i;
71 }
72
73 String
74 Duration::str () const
75 {
76   return Duration_convert::dur2_str (*this);
77 }
78
79
80 bool
81 Duration::plet_b ()
82 {
83   return !plet_.unit_b ();
84 }
85