]> git.donarmstrong.com Git - lilypond.git/blobdiff - mi2mu/mudela-score.cc
patch::: 0.1.9.jcn2: pats
[lilypond.git] / mi2mu / mudela-score.cc
index 843bab56c77b51bdfa3e4ba453910c9e5e398ef0..c8f575d04c4feac9173bda934b901a961c125a25 100644 (file)
@@ -3,6 +3,7 @@
 //
 // copyright 1997 Jan Nieuwenhuizen <jan@digicash.com>
 
+#include <assert.h>
 #include "moment.hh"
 #include "duration.hh"
 #include "duration-convert.hh"
 #include "mudela-staff.hh"
 #include "mudela-stream.hh"
 
+static Mudela_key key_c (0, 0);
+static Mudela_meter meter_4 (4, 2, 24, 8);
+// useconds per 4: 250000 === 60 4 per minute
+static Mudela_tempo tempo_60 (1000000);
+
 Mudela_score::Mudela_score (int format_i, int tracks_i, int tempo_i)
 {
   format_i_ = format_i;
   tracks_i_ = tracks_i;
   tempo_i_ = tempo_i;
-  mudela_column_p_list_.bottom().add (new Mudela_column (this, Moment (0)));
+  column_l_array_.push (new Mudela_column (this, Moment (0)));
+  mudela_key_l_ = &key_c;
+  mudela_meter_l_ = &meter_4;
+  mudela_tempo_l_ = &tempo_60;
 }
 
 Mudela_score::~Mudela_score()
@@ -38,23 +47,27 @@ Mudela_score::add_staff (Mudela_staff* mudela_staff_p)
 }
 
 Mudela_column*
-Mudela_score::mudela_column_l (Moment mom)
+Mudela_score::find_column_l (Moment mom)
+{
+  // should do binary search
+  for (int i = 0; i < column_l_array_.size (); i++ )
+    if ( column_l_array_[i]->at_mom () == mom )
+        return column_l_array_[i];
+  return 0;
+}
+
+Mudela_column*
+Mudela_score::get_column_l (Moment mom)
 {
-  for  (PCursor<Mudela_column*> i (mudela_column_p_list_); i.ok(); i++) 
+  if ( column_l_array_ [column_l_array_.size() - 1]->at_mom () > mom )
     {
-       if  (i->at_mom() > mom) 
-         {
-           Mudela_column* p = new Mudela_column (this, mom);
-           i.insert (p);
-           return p;
-         }
-       if  (i->at_mom() == mom)
-           return *i;
+      error ("ugh");
+      exit (1);
     }
+  if ( column_l_array_[column_l_array_.size() - 1]->at_mom () < mom )
+    column_l_array_.push (new Mudela_column (this, mom));
 
-  Mudela_column* p = new Mudela_column (this, mom);
-  mudela_column_p_list_.bottom().add (p);
-  return p;
+  return column_l_array_ [column_l_array_.size() - 1];
 }
 
 void
@@ -93,7 +106,7 @@ Mudela_score::output (String filename_str)
 
   mudela_stream << "\\paper{}\n";
 
-  mudela_stream << "\\midi{ ";
+  mudela_stream << "\\midi{\n";
        // let's not use silly 0 track
        mudela_staff_p_list_.bottom()->mudela_tempo_p_->output (mudela_stream);
   mudela_stream << "}\n";
@@ -107,8 +120,8 @@ Mudela_score::process()
   LOGOUT(NORMAL_ver) << "\nProcessing..." << endl;
        
   LOGOUT(DEBUG_ver) << "columns\n";
-  for  (PCursor<Mudela_column*> i (mudela_column_p_list_); i.ok(); i++)
-       LOGOUT(DEBUG_ver) << "At: " << i->at_mom() << "\n";
+//  for  (PCursor<Mudela_column*> i (mudela_column_p_list_); i.ok(); i++)
+//     LOGOUT(DEBUG_ver) << "At: " << i->at_mom() << "\n";
 
   settle_columns();
   filter_tempo();
@@ -171,12 +184,16 @@ Mudela_score::settle_columns()
 //    return;
   LOGOUT(NORMAL_ver) << "\nSettling columns..." << endl;
 
+#if 0
   assert (!column_l_array_.size());
   int n = mudela_column_p_list_.size();
 // huh?
 //    column_l_array_.set_size (n);
   for  (PCursor<Mudela_column*> i (mudela_column_p_list_); i.ok(); i++)
        column_l_array_.push (*i);
+#endif
+
+  int n = column_l_array_.size();
 
   int start_i = 0;
   int end_i = 0;