]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/recording-group-engraver.cc
* scripts/lilypond-book.py (Lilypond_snippet.is_outdated): require
[lilypond.git] / lily / recording-group-engraver.cc
index 9915c1d17f0129847864c1c4cd103c6504d1129a..16dce1646867eb259ca67fb9d1114ade84977d81 100644 (file)
@@ -3,17 +3,19 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2003 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 2003--2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
  */
 
+#include "context.hh"
 #include "engraver-group-engraver.hh"
 #include "protected-scm.hh"
 
 class Recording_group_engraver : public Engraver_group_engraver
 {
+  void start ();
 public:
-  TRANSLATOR_DECLARATIONS(Recording_group_engraver);
+  TRANSLATOR_DECLARATIONS (Recording_group_engraver);
   virtual bool try_music (Music *m);
   virtual void start_translation_timestep ();
   virtual void stop_translation_timestep ();
@@ -26,25 +28,47 @@ void
 Recording_group_engraver::initialize ()
 {
   Engraver_group_engraver::initialize ();
-  accumulator_ = gh_cons (SCM_EOL, SCM_EOL);
+  start ();
 }
 
-Recording_group_engraver::Recording_group_engraver()
+Recording_group_engraver::Recording_group_engraver ()
 {
 }
 
 void
 Recording_group_engraver::start_translation_timestep ()
 {
-  Engraver_group_engraver::start_translation_timestep();
-  
-  scm_set_car_x (accumulator_, gh_cons (now_mom ().smobbed_copy (), SCM_EOL));
+  Engraver_group_engraver::start_translation_timestep ();
+
+
+  /*
+    We have to do this both in initialize () and
+    start_translation_timestep (), since start_translation_timestep ()
+    isn't called on the first time-step.
+   */
+  start () ;
+}
+
+void
+Recording_group_engraver::start ()
+{
+  if (!gh_pair_p (accumulator_))
+    accumulator_ = gh_cons (SCM_EOL, SCM_EOL);
+  if (!gh_pair_p (gh_car (accumulator_)))
+    {
+      /*
+       Need to store transposition for every moment; transposition changes during pieces.
+       */
+      scm_set_car_x (accumulator_, gh_cons (gh_cons (now_mom ().smobbed_copy (),
+                                                    get_property ("instrumentTransposition")),
+                                                    SCM_EOL));
+    }
 }
 
 void
 Recording_group_engraver::stop_translation_timestep ()
 {
-  Engraver_group_engraver::stop_translation_timestep();
+  Engraver_group_engraver::stop_translation_timestep ();
   scm_set_cdr_x (accumulator_, gh_cons (gh_car (accumulator_), gh_cdr (accumulator_)));
 
   scm_set_car_x (accumulator_, SCM_EOL);
@@ -57,7 +81,7 @@ Recording_group_engraver::finalize ()
   SCM proc = get_property ("recordEventSequence");
 
   if (gh_procedure_p (proc))
-    scm_call_2  (proc, self_scm(), gh_cdr (accumulator_));
+    scm_call_2  (proc, daddy_context_->self_scm (), gh_cdr (accumulator_));
 
   accumulator_ = SCM_EOL;
 }
@@ -65,13 +89,10 @@ Recording_group_engraver::finalize ()
 bool
 Recording_group_engraver::try_music (Music  *m)
 {
-  bool here_success = Translator_group::try_music_on_nongroup_children (m);
-  bool retval = here_success;
-  if (!here_success && daddy_trans_)
-    retval = daddy_trans_->try_music (m);
-      
+  bool retval = Translator_group::try_music (m);
+
   SCM seq = gh_cdar (accumulator_);
-  seq = gh_cons (gh_cons  (m->self_scm(), gh_bool2scm (here_success)),
+  seq = gh_cons (gh_cons  (m->self_scm (), gh_bool2scm (retval)),
                 seq);
   
   scm_set_cdr_x  (gh_car (accumulator_), seq);
@@ -80,7 +101,7 @@ Recording_group_engraver::try_music (Music  *m)
 }
 
 
-ENTER_DESCRIPTION(Recording_group_engraver,
+ENTER_DESCRIPTION (Recording_group_engraver,
                  "Engraver_group_engraver that records all music events "
                  "for this context. Calls the procedure "
                  "in @code{recordEventSequence} when finished.",