]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.1.11
authorfred <fred>
Sun, 24 Mar 2002 19:56:02 +0000 (19:56 +0000)
committerfred <fred>
Sun, 24 Mar 2002 19:56:02 +0000 (19:56 +0000)
lily/axis-group.cc
lily/paper-def.cc
lily/score.cc
lily/scores.cc

index c0fff8176058f50db1c470a88c9213e5b5c4c05a..ac5a334e318e3bd54336f38a3ab57f713c6212d6 100644 (file)
 /** don't copy anything: an element can only be in one
   Axis_group_element at one time.  */
 Axis_group_administration::Axis_group_administration (
-  Axis_group_administration const&)
+                                                     Axis_group_administration const&)
 {
 }
 
 bool 
-Axis_group_administration::contains_b (Score_elem const *e)const
+Axis_group_administration::contains_b (Score_elem const *e) const
 {
   return elem_l_arr_.find_l (e);
 }
 
 Interval
-Axis_group_administration::extent (Axis axis)const
+Axis_group_administration::extent (Axis axis) const
 {
   Interval r;
   for (int i=0; i < elem_l_arr_.size(); i++) 
-       r.unite (elem_l_arr_[i]->extent (axis));
+    r.unite (elem_l_arr_[i]->extent (axis));
   return r;
 }
 
 void
 Axis_group_administration::add_element (Score_elem*e,
-                                      Axis_group_element*g, Axis a1, Axis a2)
+                                       Axis_group_element*g, Axis a1, Axis a2)
 {
   assert (! e->axis_group_l_a_[a1] && !e->axis_group_l_a_[a2]);
   e->axis_group_l_a_[a1] = g;
   e->axis_group_l_a_[a2] = g;    
-  elem_l_arr_.push ( e);
+  elem_l_arr_.push (e);
 }
 
 
@@ -59,9 +59,9 @@ Axis_group_administration::remove_all (Axis a1, Axis a2)
 {
   for (int i=0; i < elem_l_arr_.size(); i++) 
     {
-       Score_elem*e=elem_l_arr_[i];
-       e->axis_group_l_a_[a1] = 0;
-       e->axis_group_l_a_[a2] = 0;  
+      Score_elem*e=elem_l_arr_[i];
+      e->axis_group_l_a_[a1] = 0;
+      e->axis_group_l_a_[a2] = 0;  
     }
   elem_l_arr_.clear();
 }
@@ -72,6 +72,6 @@ Axis_group_administration::print() const
 {
 #ifndef NPRINT
   for (int i=0; i < elem_l_arr_.size(); i++) 
-       DOUT << elem_l_arr_[i]->name() << ' ';
+    DOUT << elem_l_arr_[i]->name() << ' ';
 #endif
 }
index 8950d987232b80b2bd4c9a5aa94549ce08bf7403..8bf32b14905f0ac92654bb5dcaf9bdf54c0c89a9 100644 (file)
 #include "lookup.hh"
 #include "dimen.hh"
 #include "input-translator.hh"
-#include "engraver-group.hh"
 #include "assoc-iter.hh"
+#include "score-grav.hh"
+#include "p-score.hh"
+#include "main.hh"
 
 void
 Paper_def::set_var (String s, Real r)
 {
-   real_vars_p_->elem (s) = r;
+  real_vars_p_->elem (s) = r;
 }
  
 Real
-Paper_def::get_var (String s)const
+Paper_def::get_var (String s) const
 {
   if (! real_vars_p_->elt_b (s))
-    error ( "unknown paper variable `"  + s+"'");
+    error ("unknown paper variable `"  + s+"'");
   return real_vars_p_->elem (s);
 }
 
@@ -39,7 +41,7 @@ Paper_def::linewidth_f() const
 }
 
 Real
-Paper_def::duration_to_dist (Moment d,Real k)const
+Paper_def::duration_to_dist (Moment d,Real k) const
 {
   if (get_var("geometric"))
     return geometric_spacing(d);
@@ -63,9 +65,9 @@ Paper_def::arithmetic_constant(Moment d) const
 }
 
 Real
-Paper_def::arithmetic_spacing(Moment d ,Real k)const
+Paper_def::arithmetic_spacing(Moment d ,Real k) const
 {
-  return (log_2(d) + k)* get_var( "arithmetic_multiplier");
+  return (log_2(d) + k)* get_var("arithmetic_multiplier");
 }
 
 Real
@@ -122,7 +124,7 @@ Paper_def::interline_f() const
 
 
 Real
-Paper_def::rule_thickness()const
+Paper_def::rule_thickness() const
 {
   return get_var ("rule_thickness");
 }
@@ -139,7 +141,7 @@ Paper_def::internote_f() const
 }
 
 Real
-Paper_def::note_width()const
+Paper_def::note_width() const
 {
   return get_var ("notewidth");
 }
@@ -154,7 +156,7 @@ Paper_def::print() const
   itrans_p_->print();
   for (Assoc_iter<String,Real> i (*real_vars_p_); i.ok(); i++) 
     {
-       DOUT << i.key() << "= " << i.val () << "\n";
+      DOUT << i.key() << "= " << i.val () << "\n";
     }
   DOUT << "}\n";
 #endif
@@ -168,7 +170,19 @@ Paper_def::lookup_l()
 }
 
 Global_translator*
-Paper_def::get_global_translator_p() const
+Paper_def::get_global_translator_p() 
 {
-  return  itrans_p_->get_group_engraver_p()->global_l ();
+  if (only_midi) 
+    {
+      return 0;
+    }
+
+  Global_translator* g =  itrans_p_->get_group_engraver_p()->global_l ();
+  assert (g->is_type_b (Score_engraver::static_name()));
+  Score_engraver*grav = (Score_engraver*) g;
+  grav->pscore_p_ = new Paper_score;
+  grav->pscore_p_->paper_l_ = this;
+  return g;      
 }
+
+IMPLEMENT_IS_TYPE_B1(Paper_def, Music_output_def);
index 80057719c2c14d44bc519ba7e33b26f009ad4c07..04ed82576876e348ab067782c9fcc74b74b80d1c 100644 (file)
@@ -6,19 +6,13 @@
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 
-#include "tex-stream.hh"
 #include "score.hh"
-#include "score-column.hh"
-#include "p-score.hh"
 #include "debug.hh"
-#include "paper-def.hh"
+#include "music-output-def.hh"
+#include "music-output.hh"
 #include "main.hh"
 #include "source.hh"
 #include "source-file.hh"
-#include "midi-def.hh"
-#include "midi-stream.hh"
-#include "audio-score.hh"
-#include "p-col.hh"
 #include "music-iterator.hh"
 #include "music.hh"
 #include "global-translator.hh"
@@ -30,189 +24,117 @@ Score::Score()
 {
   header_p_ = 0;
   music_p_ = 0;
-  pscore_p_ = 0;
-  audio_score_p_ = 0;
-  paper_p_ = 0;
-  midi_p_ = 0;
   errorlevel_i_ = 0;
 }
 
 Score::Score (Score const &s)
 {
-  assert (!pscore_p_);
   music_p_ = s.music_p_->clone();
-  midi_p_ = new Midi_def (*s.midi_p_);
-  paper_p_ = new Paper_def (*s.paper_p_);
+  for (int i=0; i < s.def_p_arr_.size (); i++)
+    def_p_arr_.push(s.def_p_arr_[i]->clone());
   header_p_ = new Header (*s.header_p_);
 }
 
 Score::~Score()
 {
   delete header_p_;
+  for (int i=0; i < def_p_arr_.size (); i++)
+    delete def_p_arr_[i];
   delete music_p_;
-  delete pscore_p_;
-  delete audio_score_p_;
-  delete paper_p_;
-  delete midi_p_;
 }
 
 void
-Score::run_translator (Global_translator * trans_l)
+Score::run_translator (Music_output_def *odef_l)
 {
-  trans_l->set_score (this);
+  Global_translator * trans_p = odef_l->get_global_translator_p();
+  if (!trans_p)
+    return ;
+  
+  *mlog << "\nInterpreting music ...";
+  trans_p->last_mom_ = music_p_->time_int().max ();
+
   Music_iterator * iter = Music_iterator::static_get_iterator_p (music_p_, 
-                                                                 trans_l);
+                                                                trans_p);
   iter->construct_children();
 
-  if ( ! iter->ok()) 
+  if (! iter->ok()) 
     {
-       delete iter;
-       warning ("Need music in a score");
-       errorlevel_i_ =1;
-       return ;
+      delete iter;
+      warning ("Need music in a score");
+      errorlevel_i_ =1;
+      return ;
     }
   
-  trans_l->start();
+  trans_p->start();
   
-  while ( iter->ok() || trans_l->moments_left_i ()) 
+  while (iter->ok() || trans_p->moments_left_i ()) 
     {
-       Moment w = infinity_mom;
-       if (iter->ok()) 
-         {
-           w = iter->next_moment();
-           DOUT << w;
-           iter->print();
-         }
-       trans_l->modify_next (w);
-       trans_l->prepare (w);
-       trans_l->print();
-
-       iter->process_and_next (w);
-       trans_l->process();
+      Moment w = infinity_mom;
+      if (iter->ok()) 
+       {
+         w = iter->next_moment();
+         DOUT << "proccing: " << w <<"\n";
+         iter->print();
+       }
+      trans_p->modify_next (w);
+      trans_p->prepare (w);
+      trans_p->print();
+
+      iter->process_and_next (w);
+      trans_p->process();
     }
   delete iter;
-  trans_l->finish();
-}
+  trans_p->finish();
 
-void
-Score::process()
-{
-  print();
-  paper();
-  midi();
-}
-
-void
-Score::midi()
-{
-  if ( !midi_p_)
-       return;
-  
-  *mlog << "\nCreating MIDI elements ..." << flush;
-  audio_score_p_ = new Audio_score (this);
-  
-  Global_translator* score_trans=  midi_p_->get_global_translator_p();
-  run_translator (score_trans);
-  delete score_trans;
-  
-  if (errorlevel_i_)
-    {
-       // should we? hampers debugging. 
-       warning ("Errors found, /*not processing score*/");
-    }
-  *mlog << endl;
-
-  midi_output();
-}
-  
-void
-Score::paper()
-{
-  if (!paper_p_)
-       return;
-  
-  *mlog << "\nCreating elements ..." << flush;
-  pscore_p_ = new Paper_score (paper_p_);
-  
-  Global_translator * score_trans=  paper_p_->get_global_translator_p();
-  run_translator (score_trans);
-  delete score_trans;
   
   if (errorlevel_i_) 
     {
-       // should we? hampers debugging. 
-       warning ("Errors found, /*not processing score*/");
+      // should we? hampers debugging. 
+      warning ("Errors found, /*not processing score*/");
     }
+    
+  Music_output * output = trans_p->get_output_p();
+  delete trans_p;
+
+  output->header_l_ = header_p_;
+  output->default_out_str_ = default_out_fn;
+  output->origin_str_ =  location_str();
   
   *mlog << endl;
-  pscore_p_->process();
-
-  // output
-  paper_output();
+  output->process();
+  delete output ;
 }
 
 void
-Score::midi_output()
+Score::process()
 {
-  if ( midi_p_->outfile_str_ == "")
-       midi_p_->outfile_str_ = default_out_fn + ".midi";
-
-  Midi_stream midi_stream (midi_p_->outfile_str_);    
-  *mlog << "MIDI output to " << midi_p_->outfile_str_ << " ..." << endl;    
+  if (!music_p_)
+    return;
 
-  audio_score_p_->output (midi_stream);
-  *mlog << endl;
+  print();
+  for (int i=0; i < def_p_arr_.size (); i++)
+    run_translator (def_p_arr_[i]);
 }
 
-void
-Score::paper_output()
-{
-  if (paper_p_->outfile_str_=="")
-       paper_p_->outfile_str_ = default_out_fn + ".tex";
 
-  if ( errorlevel_i_) 
-    {
-       *mlog << "lilypond: warning: no output to: " << paper_p_->outfile_str_ 
-       << " (errorlevel=" << errorlevel_i_ << ")" << endl;
-      return;
-    }
 
-  *mlog << "TeX output to " << paper_p_->outfile_str_ << " ...\n";
-  
-  Tex_stream the_output (paper_p_->outfile_str_);
-  
-  the_output << "% outputting Score, defined at: " <<
-       location_str() << "\n";
-  if (header_p_) {
-    the_output << header_p_->TeX_string();
-  }
-  pscore_p_->output (the_output);
-}
 
 void
 Score::print() const
 {
 #ifndef NPRINT
   DOUT << "score {\n"; 
-  music_p_->print();
-  if (midi_p_)
-       midi_p_->print();
-  
+  for (int i=0; i < def_p_arr_.size (); i++)
+    def_p_arr_[i]->print();
   DOUT << "}\n";
 #endif
 }
 
 void
-Score::set (Paper_def *pap_p)
+Score::add (Music_output_def *pap_p)
 {
-  delete paper_p_;
-  paper_p_ = pap_p;
+  def_p_arr_.push(pap_p);
 }
 
-void
-Score::set (Midi_def* midi_p)
-{    
-  delete midi_p_;
-  midi_p_ = midi_p;
-}
+
 
index 446e419a3da25b783eb0c13a233b0287148d0ed2..a1cb0830a1e403d70072b8f3f6df00490407249d 100644 (file)
@@ -22,11 +22,6 @@ do_scores()
     {
        Score *&is_p = score_array_global[i];
        
-       if (only_midi) 
-         {
-           delete is_p->paper_p_;
-           is_p->paper_p_ = 0;
-         }
        
        if (is_p->errorlevel_i_) 
          {