]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/recording-group-engraver.cc
* lily/text-item.cc (interpret_string): new file, select font with
[lilypond.git] / lily / recording-group-engraver.cc
index 2a0970b50961c22557d29d32339c0ec79c19eb6c..3a13dc0e25c7d2cbd72a8a20c9de5fefd0eb78df 100644 (file)
@@ -7,13 +7,15 @@
 
  */
 
+#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,26 +28,48 @@ 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 (!is_pair (accumulator_))
+    accumulator_ = scm_cons (SCM_EOL, SCM_EOL);
+  if (!is_pair (ly_car (accumulator_)))
+    {
+      /*
+       Need to store transposition for every moment; transposition changes during pieces.
+       */
+      scm_set_car_x (accumulator_, scm_cons (scm_cons (now_mom ().smobbed_copy (),
+                                                    get_property ("instrumentTransposition")),
+                                                    SCM_EOL));
+    }
 }
 
 void
 Recording_group_engraver::stop_translation_timestep ()
 {
-  Engraver_group_engraver::stop_translation_timestep();
-  scm_set_cdr_x (accumulator_, gh_cons (gh_car (accumulator_), gh_cdr (accumulator_)));
+  Engraver_group_engraver::stop_translation_timestep ();
+  scm_set_cdr_x (accumulator_, scm_cons (ly_car (accumulator_), ly_cdr (accumulator_)));
 
   scm_set_car_x (accumulator_, SCM_EOL);
 }
@@ -56,8 +80,8 @@ Recording_group_engraver::finalize ()
   Engraver_group_engraver::finalize ();
   SCM proc = get_property ("recordEventSequence");
 
-  if (gh_procedure_p (proc))
-    scm_call_2  (proc, self_scm(), gh_cdr (accumulator_));
+  if (is_procedure (proc))
+    scm_call_2  (proc, daddy_context_->self_scm (), ly_cdr (accumulator_));
 
   accumulator_ = SCM_EOL;
 }
@@ -67,17 +91,17 @@ Recording_group_engraver::try_music (Music  *m)
 {
   bool retval = Translator_group::try_music (m);
 
-  SCM seq = gh_cdar (accumulator_);
-  seq = gh_cons (gh_cons  (m->self_scm(), gh_bool2scm (retval)),
+  SCM seq = ly_cdar (accumulator_);
+  seq = scm_cons (scm_cons  (m->self_scm (), ly_bool2scm (retval)),
                 seq);
   
-  scm_set_cdr_x  (gh_car (accumulator_), seq);
+  scm_set_cdr_x  (ly_car (accumulator_), seq);
 
   return retval;
 }
 
 
-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.",