]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/score-performer.cc
release: 1.5.13
[lilypond.git] / lily / score-performer.cc
index 75e9fc2200c020a7469489602fd0c0bc220168d0..ea2926c5bc45b176a162f5c4d065587201b8c85a 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996, 1997 Jan Nieuwenhuizen <jan@digicash.com>
+  (c) 1996--2001 Jan Nieuwenhuizen <janneke@gnu.org>
  */
 
 #include "score-performer.hh"
 #include "midi-stream.hh"
 #include "string-convert.hh"
 #include "debug.hh"
-#include "score.hh"
-#include "source-file.hh"
-#include "source.hh"
-#include "audio-staff.hh"
+#include "translator-def.hh"
 
-IMPLEMENT_IS_TYPE_B1(Score_performer,Performer_group_performer);
-ADD_THIS_TRANSLATOR(Score_performer);
 
 
-Score_performer::Score_performer()
+ENTER_DESCRIPTION(Score_performer,
+/* descr */       "",
+/* creats*/       "",
+/* acks  */       "",
+/* reads */       "",
+/* write */       "");
+
+
+Score_performer::Score_performer ()
 {
+  performance_p_ = 0;
 }
 
 
-Score_performer::~Score_performer()
+Score_performer::~Score_performer ()
 {
 }
 
 void
-Score_performer::play (Audio_element * p)
+Score_performer::play_element (Audio_element * p)
 {
-  if  (p->is_type_b (Audio_item::static_name())) 
-    {
-      audio_column_l_->add ((Audio_item*)p);
-    }
-  else if (p->is_type_b (Audio_staff::static_name())) 
+  if (Audio_item * i=dynamic_cast<Audio_item *> (p)) 
     {
-      performance_p_->add_staff ((Audio_staff*)p);
+      audio_column_l_->add_audio_item (i);
     }
-  performance_p_->add (p);
+  performance_p_->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);
+  */
 }
 
 void 
@@ -51,36 +66,38 @@ Score_performer::prepare (Moment m)
 {
   Global_translator::prepare (m);
   audio_column_l_ = new Audio_column (m);
-  performance_p_->add (audio_column_l_);
-  post_move_processing ();
+  play_element (audio_column_l_);
+  start_translation_timestep ();
 }
 
 
 void 
-Score_performer::process()
+Score_performer::one_time_step ()
 {
-  process_requests();
-  pre_move_processing();
-  check_removal();
+  // fixme: put this back.
+  // process_music ();
+  announces ();
+  stop_translation_timestep ();
+  check_removal ();
 }
 
 void
-Score_performer::start()
+Score_performer::start ()
 {
 }
 
 
 int
-Score_performer::get_tempo_i() const
+Score_performer::get_tempo_i () const
 {
-  return performance_p_->midi_l_->get_tempo_i (Moment (1, 4));
+  return performance_p_->midi_l_->get_tempo_i (Moment (Rational (1, 4)));
 }
 
 void
-Score_performer::finish()
+Score_performer::finish ()
 {
   check_removal ();
-  removal_processing();
+  removal_processing ();
 }
 
 Music_output *
@@ -92,10 +109,12 @@ Score_performer::get_output_p ()
 }
 
 void
-Score_performer::add_processing ()
+Score_performer::initialize ()
 {
-  Translator_group::add_processing ();
-  assert (output_def_l_->is_type_b (Midi_def::static_name ()));
+  unsmob_translator_def (definition_)->apply_property_operations (this);
+  assert (dynamic_cast<Midi_def *> (output_def_l_));
   performance_p_ = new Performance;
-  performance_p_->midi_l_ = (Midi_def*) output_def_l_;  
+  performance_p_->midi_l_ = dynamic_cast<Midi_def*> (output_def_l_);
+
+  Translator_group::initialize ();
 }