]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/score-performer.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / score-performer.cc
index 317bc3ac9dbaadc7d218e04a736e2dda4d609485..5bff2797dac2ded126f08553acd8e2a15e166544 100644 (file)
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996--2000 Jan Nieuwenhuizen <janneke@gnu.org>
- */
+  (c) 1996--2006 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
 
+#include "moment.hh"
 #include "score-performer.hh"
-#include "midi-def.hh"
+
 #include "audio-column.hh"
 #include "audio-item.hh"
 #include "performance.hh"
 #include "midi-stream.hh"
 #include "string-convert.hh"
-#include "debug.hh"
-#include "translator-def.hh"
-
-ADD_THIS_TRANSLATOR (Score_performer);
-
+#include "warn.hh"
+#include "context-def.hh"
+#include "output-def.hh"
+#include "context.hh"
+
+ADD_TRANSLATOR_GROUP (Score_performer,
+                     /* doc */ "",
+                     /* create */ "",
+                     /* accept */ "",
+                     /* read */ "",
+                     /* write */ "");
 
 Score_performer::Score_performer ()
 {
-  performance_p_ = 0;
+  performance_ = 0;
+  skipping_ = false;
 }
 
-
 Score_performer::~Score_performer ()
 {
 }
 
 void
-Score_performer::play_element (Audio_element * p)
+Score_performer::play_element (Audio_element *p)
 {
-  if  (Audio_item * i=dynamic_cast<Audio_item *> (p)) 
-    {
-      audio_column_l_->add_audio_item (i);
-    }
-  performance_p_->add_element (p);
+  if (Audio_item *i = dynamic_cast<Audio_item *> (p))
+    audio_column_->add_audio_item (i);
+  performance_->add_element (p);
 }
 
 void
 Score_performer::announce_element (Audio_element_info info)
 {
-  announce_info_arr_.push (info);
-
-
-  /*
-    huh?
-    copied from score-engraver, but
-    this way staff gets in list twice
-  if (Audio_item* i = dynamic_cast<Audio_item*> (info.elem_l_))
-    performance_p_->add_element (i);
-  */
+  announce_infos_.push_back (info);
 }
 
-void 
+void
 Score_performer::prepare (Moment m)
 {
-  Global_translator::prepare (m);
-  audio_column_l_ = new Audio_column (m);
-  play_element (audio_column_l_);
-  post_move_processing ();
+  audio_column_ = new Audio_column (m);
+  play_element (audio_column_);
+  precomputed_recurse_over_translators (context (), START_TRANSLATION_TIMESTEP, UP);
 }
 
-
-void 
-Score_performer::process()
+void
+Score_performer::finish ()
 {
-  //process_music();
-  announces ();
-  pre_move_processing();
-  check_removal();
+  recurse_over_translators (context (),
+                           &Translator::finalize,
+                           &Translator_group::finalize,
+                           UP);
 }
 
 void
-Score_performer::start()
+Score_performer::one_time_step ()
 {
-}
+  if (to_boolean (context ()->get_property ("skipTypesetting")))
+    {
+      if (!skipping_)
+        {
+         skip_start_mom_ = audio_column_->at_mom ();
+         skipping_ = true;
+        }
+    }
+  else
+    {
+      if (skipping_)
+        {
+         offset_mom_ -= audio_column_->at_mom () - skip_start_mom_;
+         skipping_ = false;
+       }
+
+      audio_column_->offset_at_mom (offset_mom_);
+      precomputed_recurse_over_translators (context (), PROCESS_MUSIC, UP);
+      do_announces ();
+    }
 
+  precomputed_recurse_over_translators (context (), STOP_TRANSLATION_TIMESTEP, UP);
+}
 
 int
-Score_performer::get_tempo_i() const
+Score_performer::get_tempo () const
 {
-  return performance_p_->midi_l_->get_tempo_i (Moment (1, 4));
+  return ::get_tempo (performance_->midi_, Moment (Rational (1, 4)));
 }
 
-void
-Score_performer::finish()
+SCM
+Score_performer::get_output ()
 {
-  check_removal ();
-  removal_processing();
+  Music_output *o = performance_;
+  performance_ = 0;
+  return o->self_scm ();
 }
 
-Music_output *
-Score_performer::get_output_p ()
+void
+Score_performer::derived_mark () const
 {
-  Music_output * o = performance_p_;
-  performance_p_ =0;
-  return o;
+  if (performance_)
+    scm_gc_mark (performance_->self_scm ());
+
+  Score_translator::derived_mark ();
+  Performer_group::derived_mark ();
 }
 
 void
 Score_performer::initialize ()
 {
-  unsmob_translator_def (definition_)->apply_property_operations (this);
-  assert (dynamic_cast<Midi_def *> (output_def_l_));
-  performance_p_ = new Performance;
-  performance_p_->midi_l_ = dynamic_cast<Midi_def*>(output_def_l_);
+  performance_ = new Performance;
+  performance_->unprotect ();
+  performance_->midi_ = context ()->get_output_def ();
 
   Translator_group::initialize ();
 }