]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.1.9
authorfred <fred>
Sun, 24 Mar 2002 19:54:17 +0000 (19:54 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:54:17 +0000 (19:54 +0000)
lib/duration.cc
lib/include/plet.hh [new file with mode: 0644]
lib/plet.cc [new file with mode: 0644]
lily/command-request.cc
lily/identifier.cc
lily/include/identifier.hh

index fab55e756c9a10e786667dc476068517c7b444fa..c26699c5bd773d3f38dc408a901feded7a24fe42 100644 (file)
@@ -22,22 +22,25 @@ int Duration::division_1_i_s = 384 * 4;
 
 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 )
+{
+  durlog_i_ = type_i;
+  dots_i_ = dots_i;
+  ticks_i_ = 0;
 }
 
 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;
+  /*
+    ugh. Assuming behavior of conversion funcs on broken input.
+   */
+  return t == Duration_convert::type2_i( Duration_convert::i2_type(t));
 }
 
 // ugh, what's this?
@@ -45,58 +48,40 @@ Duration::duration_type_b(int t)
 Moment
 Duration::length() const
 {
-    return Duration_convert::dur2_mom(*this);
+  return Duration_convert::dur2_mom(*this);
 }
 
 void
 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)
 {
-    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 )
 {
-       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);
+  return Duration_convert::dur2_str(*this);
 }
 
-Plet::Plet()
-{
-    type_i_ = 1;
-    iso_i_ = 1;
-}
-
-Moment
-Plet::mom()const
-{
-    return  Moment( iso_i_, type_i_ );
-}
 
 bool
 Duration::plet_b()
 {
-    return !plet_.unit_b();
+  return !plet_.unit_b();
 }
-
-bool
-Plet::unit_b()const
-{
-    return type_i_ == 1 && iso_i_ == 1;
-}
-
diff --git a/lib/include/plet.hh b/lib/include/plet.hh
new file mode 100644 (file)
index 0000000..1f1033f
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+  plet.hh -- declare Plet
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef PLET_HH
+#define PLET_HH
+#include "moment.hh"
+
+/** 
+  The type and replacement value of a  plet (triplet, quintuplet.) Conceptually the same as a rational, but 4/6 != 2/3.
+  
+  (plet)
+ */
+struct Plet {
+  Plet();
+  Moment mom()const;
+  bool unit_b()const;
+  int iso_i_;  // 2/3; 2 is not duration, maar of count!
+  int type_i_; 
+};
+
+#endif // PLET_HH
diff --git a/lib/plet.cc b/lib/plet.cc
new file mode 100644 (file)
index 0000000..73df524
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+  plet.cc -- implement Plet
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "plet.hh"
+
+
+Plet::Plet()
+{
+  type_i_ = 1;
+  iso_i_ = 1;
+}
+
+Moment
+Plet::mom()const
+{
+  return  Moment( iso_i_, type_i_ );
+}
+
+bool
+Plet::unit_b()const
+{
+  return type_i_ == 1 && iso_i_ == 1;
+}
+
index 1c77d60f0f80d16cc04cc213833e0562045c14fd..051ce84465731951952cc2894cf32f607ec4158c 100644 (file)
@@ -24,21 +24,21 @@ void
 Cadenza_req::do_print()const
 {
 #ifndef NPRINT
-    DOUT << on_b_;
+  DOUT << on_b_;
 #endif
 }
 
 bool
 Cadenza_req::do_equal_b (Request*r)const
 {
-    Cadenza_req*cad =  r->command()->timing ()->cadenza ();
-    
-    return cad->on_b_ == on_b_;
+  Cadenza_req*cad =  r->command()->timing ()->cadenza ();
+  
+  return cad->on_b_ == on_b_;
 }
 
 Cadenza_req::Cadenza_req (bool b)
 {
-    on_b_ =b;
+  on_b_ =b;
 }
 /* *************** */
 
@@ -46,8 +46,8 @@ Cadenza_req::Cadenza_req (bool b)
 bool
 Bar_req::do_equal_b (Request*r)const
 {
-    Bar_req * b = r->command()->bar ();
-    return type_str_ == b->type_str_;
+  Bar_req * b = r->command()->bar ();
+  return type_str_ == b->type_str_;
 }
 
 
@@ -56,25 +56,25 @@ IMPLEMENT_IS_TYPE_B1(Bar_req,Command_req);
 void
 Bar_req::do_print() const
 {
-    DOUT << type_str_;
+  DOUT << type_str_;
 }
 
 Bar_req::Bar_req (String s)
 {
-    type_str_ = s;
+  type_str_ = s;
 }
 
 Partial_measure_req::Partial_measure_req (Moment m)
 {
-    duration_ =m;
+  duration_ =m;
 }
 
 bool
 Partial_measure_req::do_equal_b (Request* r)const
 {
-    Partial_measure_req *p = r->command()->timing ()->partial ();
+  Partial_measure_req *p = r->command()->timing ()->partial ();
 
-    return p->duration_ == duration_;
+  return p->duration_ == duration_;
 }
 
 
@@ -105,7 +105,7 @@ Barcheck_req::do_print() const{}
 bool
 Barcheck_req::do_equal_b (Request*)const
 {
-    return true;
+  return true;
 }
 /* *************** */
 
@@ -115,13 +115,13 @@ void
 Clef_change_req::do_print() const
 {
 #ifndef NPRINT
-    DOUT << clef_str_ ;
+  DOUT << clef_str_ ;
 #endif
 }
 
 Clef_change_req::Clef_change_req (String s)
 {
-    clef_str_ = s;
+  clef_str_ = s;
 }
 /* *************** */
 
@@ -131,7 +131,7 @@ void
 Group_feature_req::do_print() const
 {
 #ifndef NPRINT
-    DOUT << type_str_ << "=" << value_str_;
+  DOUT << type_str_ << "=" << value_str_;
 #endif
 }
 
@@ -143,7 +143,7 @@ IMPLEMENT_IS_TYPE_B1(Partial_measure_req,Timing_req);
 void
 Partial_measure_req::do_print() const
 {
-    DOUT << duration_;
+  DOUT << duration_;
 }
 
 
@@ -153,52 +153,52 @@ void
 Meter_change_req::do_print() const
 {
 #ifndef NPRINT
-    DOUT << beats_i_ << "/" << one_beat_i_;
+  DOUT << beats_i_ << "/" << one_beat_i_;
 #endif
 }
 
 bool
 Meter_change_req::do_equal_b (Request * r)const
 {
-    Meter_change_req * m = r->command()->timing ()->meterchange ();
-    
-    return m->beats_i_ == beats_i_ 
+  Meter_change_req * m = r->command()->timing ()->meterchange ();
+  
+  return m->beats_i_ == beats_i_ 
        && one_beat_i_ == m->one_beat_i_;
 }
 
 Meter_change_req::Meter_change_req()
 {
-    beats_i_ = 0;
-    one_beat_i_ =0;
+  beats_i_ = 0;
+  one_beat_i_ =0;
 }
 
 void
 Meter_change_req::set (int b,int o)
 {
-    beats_i_=b;
-    one_beat_i_=o;
+  beats_i_=b;
+  one_beat_i_=o;
 }
 
 
 Tempo_req::Tempo_req()
 {
-    metronome_i_ = 60;
-    dur_. type_i_ = 4;
+  metronome_i_ = 60;
+  dur_. durlog_i_ = 2;
 }
 
 void
 Tempo_req::do_print()const
 {
-    DOUT << dur_.str() << " = " <<metronome_i_ ;
+  DOUT << dur_.str() << " = " <<metronome_i_ ;
 }
 IMPLEMENT_IS_TYPE_B1(Tempo_req, Timing_req);
 
 bool
 Tempo_req::do_equal_b (Request *r)const
 {
-    Tempo_req *t = r->command()->timing ()->tempo ();
-    
-    return t->dur_.length()== dur_.length () && metronome_i_ == t->metronome_i_;
+  Tempo_req *t = r->command()->timing ()->tempo ();
+  
+  return t->dur_.length()== dur_.length () && metronome_i_ == t->metronome_i_;
 }
 
 /* *************** */
@@ -209,7 +209,8 @@ IMPLEMENT_IS_TYPE_B1(Measure_grouping_req,Timing_req);
 void
 Measure_grouping_req::do_print() const
 {
-    for (int i=0; i < elt_length_arr_.size(); i++) {
+  for (int i=0; i < elt_length_arr_.size(); i++) 
+    {
        DOUT << beat_i_arr_[i] <<"*" << elt_length_arr_[i]<<" ";
     }
 }
@@ -218,7 +219,7 @@ Measure_grouping_req::do_print() const
 bool 
 Measure_grouping_req::do_equal_b (Request*)const
 {
-    return false;              // todo
+  return false;                // todo
 }
 
 /* *************** */
@@ -226,8 +227,9 @@ Measure_grouping_req::do_equal_b (Request*)const
 void
 Key_change_req::transpose (Melodic_req const & d)const
 {
-    WARN << "don't know how to transpose a key. \n";
-    for (int i=0; i < melodic_p_arr_.size(); i++) {
+  WARN << "don't know how to transpose a key. \n";
+  for (int i=0; i < melodic_p_arr_.size(); i++) 
+    {
        melodic_p_arr_[i]->transpose (d);
     }
 }
@@ -237,7 +239,8 @@ IMPLEMENT_IS_TYPE_B1(Key_change_req,Command_req);
 void
 Key_change_req::squash_octaves()
 {
-    for (int i=0; i < melodic_p_arr_.size(); i++) {
+  for (int i=0; i < melodic_p_arr_.size(); i++) 
+    {
        melodic_p_arr_[i]->octave_i_ = 0;
     }
 }
@@ -246,7 +249,8 @@ void
 Key_change_req::do_print() const
 {
 #ifndef NPRINT
-    for (int i=0; i < melodic_p_arr_.size(); i++) {
+  for (int i=0; i < melodic_p_arr_.size(); i++) 
+    {
        melodic_p_arr_[i]->print();
     }
 #endif
@@ -276,12 +280,13 @@ int
 Key_change_req::flats_i()
 {
        int flats_i = 0;
-       for ( int i = 0; i < melodic_p_arr_.size(); i++) {
+       for ( int i = 0; i < melodic_p_arr_.size(); i++) 
+         {
                Melodic_req* mel_l = melodic_p_arr_[i]->melodic();
                assert (mel_l);
                if ( mel_l->accidental_i_ < 0)
                        flats_i -= mel_l->accidental_i_;
-       }
+         }
        return flats_i;
 }
 
@@ -295,12 +300,13 @@ int
 Key_change_req::sharps_i()
 {
        int sharps_i = 0;
-       for ( int i = 0; i < melodic_p_arr_.size(); i++) {
+       for ( int i = 0; i < melodic_p_arr_.size(); i++) 
+         {
                Melodic_req* mel_l = melodic_p_arr_[i]->melodic();
                assert (mel_l);
                if ( mel_l->accidental_i_ > 0)
                        sharps_i+= mel_l->accidental_i_;
-       }
+         }
        return sharps_i;
 }
 
index ff75e9331158187935a11bc3247b966dc74b42e0..ad7f5de1f4664be02b4bc44a8eb2b2793fdb52f6 100644 (file)
@@ -24,36 +24,36 @@ IMPLEMENT_IS_TYPE_B(Identifier);
 
 Identifier::~Identifier()
 {
-    if (!accessed_b_ && !init_b_)
+  if (!accessed_b_ && !init_b_)
        warning ("Variable not used");
 }
 void
 Identifier::error (String expect)
 {
-    String e ("Wrong identifier type: ");
-    e += String (name()) + "(expected " + expect + ")";
-    ::error (e);
+  String e ("Wrong identifier type: ");
+  e += String (name()) + "(expected " + expect + ")";
+  ::error (e);
 }
 
 Identifier::Identifier ( int code)
 {
-    token_code_i_ = code; 
-    accessed_b_ = 0;
-    init_b_ = 0;
+  token_code_i_ = code; 
+  accessed_b_ = 0;
+  init_b_ = 0;
 }
 
 void
 Identifier::print()const
 {
-    DOUT << "identifier ";
-    do_print();
+  DOUT << "identifier ";
+  do_print();
 }
 
 /* ugh. */
 #define DEFAULT_PRINT(Class, Content_type, accessor) \
 void \
 Class::do_print() const { \
-    ((Class*)this)->accessor()->print(); \
+  ((Class*)this)->accessor()->print(); \
 } \
 class Class
 
@@ -68,24 +68,29 @@ DEFAULT_PRINT(Score_id, Score, score);
 DEFAULT_PRINT(Midi_def_id,Midi_def, mididef);
 DEFAULT_PRINT(Paper_def_id,Paper_def, paperdef);
 
+
+void
+Duration_id::do_print()const
+{}
+
 void
 Real_id::do_print() const
 {
-    DOUT << *data_p_<< "\n";
+  DOUT << *data_p_<< "\n";
 }
 
 void
 Int_id::do_print() const
 {
-    DOUT << *data_p_<< "\n";
+  DOUT << *data_p_<< "\n";
 }
 
 
 #define DEFAULT_ACCESSOR(Idclass, Class, accessor)\
 Class*\
 Idclass::accessor () {\
-    accessed_b_ = true;\
-    return new Class (*data_p_);\
+  accessed_b_ = true;\
+  return new Class (*data_p_);\
 }
 
 #define VIRTUAL_ACCESSOR(Idclass, Class, accessor)\
@@ -100,7 +105,7 @@ Idclass::accessor () {\
        Idclass::~Idclass() { delete data_p_; }\
        Idclass::Idclass (Class*st, int code):Identifier (code) { data_p_ = st; }\
 
-
+IMPLEMENT_ID_CLASS(Duration_id, Duration, duration);
 IMPLEMENT_ID_CLASS(Input_translator_id, Input_translator, input_translator);
 IMPLEMENT_ID_CLASS(Int_id, int, intid);
 IMPLEMENT_ID_CLASS(Real_id, Real, real);
@@ -115,9 +120,10 @@ IMPLEMENT_ID_CLASS(Paper_def_id, Paper_def, paperdef);
 
 Identifier::Identifier (Identifier const&)
 {
-    assert (false);
+  assert (false);
 }
 
+DEFAULT_ACCESSOR(Duration_id, Duration, duration);
 DEFAULT_ACCESSOR(Input_translator_id,Input_translator, input_translator);
 DEFAULT_ACCESSOR(Int_id, int, intid);
 DEFAULT_ACCESSOR(Real_id, Real, real);
index 08e8346e80ccbc974114196b799db2d02a48b663..dd4b8f75f82b5577381f95454ccce8643217fdd0 100644 (file)
@@ -42,6 +42,7 @@ struct Identifier : public Input {
     IDACCESSOR(Request, request)
     IDACCESSOR(Score, score)
     IDACCESSOR(int, intid)
+    IDACCESSOR(Duration, duration)
 
 protected:
     virtual void do_print()const=0;
@@ -61,6 +62,7 @@ struct Idclass : Identifier {\
 
 
 DECLARE_ID_CLASS(Input_translator_id, Input_translator, input_translator);
+DECLARE_ID_CLASS(Duration_id, Duration, duration);
 DECLARE_ID_CLASS(Real_id, Real, real);
 DECLARE_ID_CLASS(Script_id, General_script_def, script);
 DECLARE_ID_CLASS(Lookup_id, Lookup, lookup);