]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/score-performer.cc
Issue4107/2: Score_performer::prepare: precomputed_recurse_over_translators should...
[lilypond.git] / lily / score-performer.cc
index f47963f5e9ae43405dbb7b4ef4baf5fc92cf7113..e402b665c17e57f0ce98aeb8e4b6902c2274cf2a 100644 (file)
@@ -1,7 +1,7 @@
 /*
   This file is part of LilyPond, the GNU music typesetter.
 
-  Copyright (C) 1996--2011 Jan Nieuwenhuizen <janneke@gnu.org>
+  Copyright (C) 1996--2014 Jan Nieuwenhuizen <janneke@gnu.org>
 
   LilyPond is free software: you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
@@ -106,12 +106,12 @@ IMPLEMENT_LISTENER (Score_performer, prepare);
 void
 Score_performer::prepare (SCM sev)
 {
-  Stream_event *ev = unsmob_stream_event (sev);
+  Stream_event *ev = Stream_event::unsmob (sev);
   SCM sm = ev->get_property ("moment");
-  Moment *m = unsmob_moment (sm);
+  Moment *m = Moment::unsmob (sm);
   audio_column_ = new Audio_column (*m);
   announce_element (Audio_element_info (audio_column_, 0));
-  precomputed_recurse_over_translators (context (), START_TRANSLATION_TIMESTEP, UP);
+  precomputed_recurse_over_translators (context (), START_TRANSLATION_TIMESTEP, START);
 }
 
 IMPLEMENT_LISTENER (Score_performer, finish);
@@ -124,13 +124,24 @@ Score_performer::finish (SCM)
   recurse_over_translators (context (),
                             &Translator::finalize,
                             &Translator_group::finalize,
-                            UP);
+                            STOP);
 }
 
 IMPLEMENT_LISTENER (Score_performer, one_time_step);
 void
 Score_performer::one_time_step (SCM)
 {
+  // audio_column_ can be 0 when prepare has not been called.  The
+  // condition is triggered when Simple_music_iterator implicitly
+  // creates a Score context, like when writing
+  //
+  // \score { { | c4 c c c } \midi { } }
+  //
+  // The same situation happens with the Score_engraver group, but it
+  // would appear not to suffer any bad side effects.
+
+  if (!audio_column_)
+    audio_column_ = new Audio_column (context ()->now_mom ());
   if (to_boolean (context ()->get_property ("skipTypesetting")))
     {
       if (!skipping_)
@@ -148,11 +159,11 @@ Score_performer::one_time_step (SCM)
         }
 
       audio_column_->offset_when (offset_mom_);
-      precomputed_recurse_over_translators (context (), PROCESS_MUSIC, UP);
+      precomputed_recurse_over_translators (context (), PROCESS_MUSIC, STOP);
       do_announces ();
     }
 
-  precomputed_recurse_over_translators (context (), STOP_TRANSLATION_TIMESTEP, UP);
+  precomputed_recurse_over_translators (context (), STOP_TRANSLATION_TIMESTEP, STOP);
 }
 
 void
@@ -174,4 +185,3 @@ Score_performer::initialize ()
 
   Translator_group::initialize ();
 }
-