lilypond-0.1.11
[lilypond.git] / lib / duration.cc
blob24ae6b5da69ad6f38275c649db1dad4a3d3b7212
1 /*
2 duration.cc -- implement Duration, Plet,
4 source file of the LilyPond music typesetter
6 (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
7 Han-Wen Nienhuys <hanwen@stack.nl>
8 */
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"
20 // statics Duration
21 int Duration::division_1_i_s = 384 * 4;
24 Duration::Duration()
26 durlog_i_ = 0;
27 dots_i_ = 0;
28 ticks_i_ = 0;
31 bool
32 Duration::duration_type_b(int t)
35 ugh. Assuming behavior of conversion funcs on broken input.
37 return t == Duration_convert::type2_i( Duration_convert::i2_type(t));
40 // ugh, what's this?
41 // i should be called "mom()", ... or at least "length_mom()"
42 Moment
43 Duration::length() const
45 return Duration_convert::dur2_mom(*this);
48 void
49 Duration::set_plet(int i, int t)
51 plet_.iso_i_ = i;
52 plet_.type_i_ = t;
55 void
56 Duration::set_plet(Duration d)
58 plet_.iso_i_ = d.plet_.iso_i_;
59 plet_.type_i_ = d.plet_.type_i_;
62 void
63 Duration::set_ticks( int ticks_i )
65 assert( durlog_i_ <10 );
66 assert( !dots_i_ );
67 ticks_i_ = ticks_i;
70 String
71 Duration::str()const
73 return Duration_convert::dur2_str(*this);
77 bool
78 Duration::plet_b()
80 return !plet_.unit_b();