(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
-// split into 4?
-
#include "proto.hh"
#include "plist.hh"
#include "string.hh"
#include "source.hh"
#include "moment.hh"
#include "duration.hh"
-#include "debug.hh" //ugh
#include "duration-convert.hh"
// statics Duration
int Duration::division_1_i_s = 384 * 4;
+bool
+Duration::duration_type_b(int t)
+{
+ int bit_i=0;
+ while (t > 0)
+ {
+ int rem = t % 2;
+ t /= 2;
+ bit_i += (rem == 1);
+ }
+ return bit_i == 1;
+}
+
Duration::Duration( int type_i, int dots_i = 0)
{
+ assert(duration_type_b(type_i));
type_i_ = type_i;
dots_i_ = dots_i;
ticks_i_ = 0;
(dur)
*/
struct Duration {
- /* actually i hate it when other people use default arguments,
- because it makes you easily loose track of what-s really
- happening; in the routine-s implementation you-re not aware
- of this defaultness (who sets this stupid value?).*/
+ /**
+ Ctor of Duration. type_i should be a power of 2.
+ */
Duration( int type_i = 1, int dots_i = 0);
/// is the "plet factor" of this note != 1 ?
bool plet_b();
String str()const;
void set_plet(int,int );
+ static bool duration_type_b(int t);
void set_ticks( int ticks_i );
Moment length() const ; // zo naai mij
static int division_1_i_s;