]> git.donarmstrong.com Git - lilypond.git/blobdiff - lib/duration.cc
release: 1.0.15
[lilypond.git] / lib / duration.cc
index f81b3c2be92ed9d0e74ee6248259b2ac7a7aa7b9..f65348ae6daa2a199124f5e49867bf42bf7ef337 100644 (file)
@@ -3,10 +3,11 @@
 
   source file of the LilyPond music typesetter
 
-  (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
-           Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
+           Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
+#include <assert.h>
 #include "proto.hh"
 #include "plist.hh"
 #include "string.hh"
 #include "moment.hh"
 #include "duration.hh"
 #include "duration-convert.hh"
+#include "duration-iter.hh"
 
 // statics Duration
 int Duration::division_1_i_s = 384 * 4;
 
 
-Duration::Duration()
+Duration::Duration ()
 {
-       type_i_ = 1;
-       dots_i_ = 0;
-       ticks_i_ = 0;
+  durlog_i_ = 0;
+  dots_i_ = 0;
+  ticks_i_ = 0;
 }
 
-Duration::Duration( int type_i, int dots_i = 0 )
+bool
+Duration::duration_type_b (int t)
 {
-       type_i_ = type_i;
-       dots_i_ = dots_i;
-       ticks_i_ = 0;
+  /*
+    ugh. Assuming behavior of conversion funcs on broken input.
+   */
+  return t == Duration_convert::type2_i (Duration_convert::i2_type (t));
 }
 
-bool
-Duration::duration_type_b(int t)
+void
+Duration::compress (Moment m)
 {
-    int bit_i=0;
-    while (t > 0)
-    {
-       int rem = t % 2;
-       t /= 2;
-       bit_i += (rem == 1);
-    }
-    return bit_i == 1;
+  plet_.iso_i_ *= m.num_i ();
+  plet_.type_i_ *= m.den_i (); 
 }
 
 // ugh, what's this?
-// i should be called "mom()", ... or at least "length_mom()"
+// i should be called "mom ()", ... or at least "length_mom ()"
 Moment
-Duration::length() const
+Duration::length () const
 {
-    return Duration_convert::dur2_mom(*this);
+  return Duration_convert::dur2_mom (*this);
 }
 
 void
-Duration::set_plet(int i, int t)
+Duration::set_plet (int i, int t)
 {
-    plet_.iso_i_ = i; 
-    plet_.type_i_ = t;
+  plet_.iso_i_ = i; 
+  plet_.type_i_ = t;
 }
 
+/*
 void
-Duration::set_plet(Duration d)
+Duration::set_plet (Duration d)
 {
-    plet_.iso_i_ = d.plet_.iso_i_; 
-    plet_.type_i_ = d.plet_.type_i_;
+  plet_.iso_i_ = d.plet_.iso_i_; 
+  plet_.type_i_ = d.plet_.type_i_;
 }
+*/
 
 void
-Duration::set_ticks( int ticks_i )
+Duration::set_ticks (int ticks_i)
 {
-       assert( !type_i_ );
-       assert( !dots_i_ );
-       ticks_i_ = ticks_i;
+  assert (durlog_i_ <10);
+  assert (!dots_i_);
+  ticks_i_ = ticks_i;
 }
 
 String
-Duration::str()const
-{
-    return Duration_convert::dur2_str(*this);
-}
-
-Plet::Plet()
+Duration::str () const
 {
-    type_i_ = 1;
-    iso_i_ = 1;
+  return Duration_convert::dur2_str (*this);
 }
 
-Moment
-Plet::mom()const
-{
-    return  Moment( iso_i_, type_i_ );
-}
-
-bool
-Duration::plet_b()
-{
-    return !plet_.unit_b();
-}
 
 bool
-Plet::unit_b()const
+Duration::plet_b ()
 {
-    return type_i_ == 1 && iso_i_ == 1;
+  return !plet_.unit_b ();
 }