]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/ambitus-engraver.cc
(find_create_context): assign to lvalue.
[lilypond.git] / lily / ambitus-engraver.cc
index fb153cf5e572f9c681fcc48f35d1a8708993dff2..ee8c1c47c507c205a4efaa0ff0426bf67fbca143 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (C) 2002 Juergen Reuter <reuter@ipd.uka.de>
+  (c) 2002--2004 Juergen Reuter <reuter@ipd.uka.de>
 */
 
 #include "engraver.hh"
 #include "event.hh"
 #include "pitch.hh"
 
+
+/*
+  UGH UGH UGH .
+
+  rewrite this complely. --hwn
+ */
+
 /*
  * This class implements an engraver for ambitus grobs.
  *
@@ -63,7 +70,7 @@
 class Ambitus_engraver : public Engraver
 {
 public:
-TRANSLATOR_DECLARATIONS(Ambitus_engraver);
+TRANSLATOR_DECLARATIONS (Ambitus_engraver);
   virtual void process_music ();
   virtual void acknowledge_grob (Grob_info);
   virtual void stop_translation_timestep ();
@@ -72,7 +79,7 @@ TRANSLATOR_DECLARATIONS(Ambitus_engraver);
 private:
   void create_ambitus ();
   Item *ambitus_;
-  int/*bool*/ is_typeset;
+  bool is_typeset;
   Pitch pitch_min, pitch_max;
 };
 
@@ -85,8 +92,8 @@ Ambitus_engraver::Ambitus_engraver ()
    * (pitch_min > pitch_max) means that pitches are not yet
    * initialized
    */
-  pitch_min = Pitch (0, 0, +1);
-  pitch_max = Pitch (0, 0, -1);
+  pitch_min = Pitch (0, 0, SHARP);
+  pitch_max = Pitch (0, 0, FLAT);
 }
 
 void
@@ -109,22 +116,22 @@ Ambitus_engraver::stop_translation_timestep ()
   if (ambitus_ && !is_typeset)
     {
       /*
-       * Evaluate centralCPosition not until now, since otherwise we
+       * Evaluate middleCPosition not until now, since otherwise we
        * may then oversee a clef that is defined in a staff context if
-       * we are in a voice context; centralCPosition would then be
+       * we are in a voice context; middleCPosition would then be
        * assumed to be 0.
        */
-      SCM c0 = get_property ("centralCPosition");
-      ambitus_->set_grob_property ("c0-position", c0);
+      SCM c0 = get_property ("middleCPosition");
+      ambitus_->set_property ("c0-position", c0);
 
       /*
        * Similar for keySignature.
        */
       SCM key_signature = get_property ("keySignature");
-      ambitus_->set_grob_property ("accidentals", key_signature);
+      ambitus_->set_property ("accidentals", key_signature);
 
       typeset_grob (ambitus_);
-      is_typeset = 1;
+      is_typeset = true;
     }
 }
 
@@ -139,7 +146,7 @@ Ambitus_engraver::acknowledge_grob (Grob_info info)
          Music *nr = info.music_cause ();
          if (nr && nr->is_mus_type ("note-event"))
            {
-             Pitch pitch = *unsmob_pitch (nr->get_mus_property ("pitch"));
+             Pitch pitch = *unsmob_pitch (nr->get_property ("pitch"));
              if (Pitch::compare (pitch_min, pitch_max) > 0) // already init'd?
                {
                  // not yet init'd; use current pitch to init min/max
@@ -162,8 +169,8 @@ Ambitus_engraver::acknowledge_grob (Grob_info info)
 void
 Ambitus_engraver::create_ambitus ()
 {
-  SCM basicProperties = get_property ("Ambitus");
-  ambitus_ = new Item (basicProperties); is_typeset = 0;
+  ambitus_ = make_item ("Ambitus");
+  is_typeset = false;          
   announce_grob (ambitus_, SCM_EOL);
 }
 
@@ -173,12 +180,12 @@ Ambitus_engraver::finalize ()
   if (ambitus_)
     {
       if (Pitch::compare (pitch_min, pitch_max) <= 0)
-       {
-         ambitus_->set_grob_property ("pitch-min",
-                                        pitch_min.smobbed_copy ());
-         ambitus_->set_grob_property ("pitch-max",
-                                        pitch_max.smobbed_copy ());
-       }
+       {
+         ambitus_->set_property ("pitch-min",
+                                 pitch_min.smobbed_copy ());
+         ambitus_->set_property ("pitch-max",
+                                 pitch_max.smobbed_copy ());
+       }
       else // have not seen any pitch, so forget about the ambitus
        {
          /*
@@ -186,15 +193,12 @@ Ambitus_engraver::finalize ()
           * most probably arises from an empty voice, such as shared
           * global timesig/clef definitions.
           */
-#if 0
-         ambitus_->warning("empty ambitus range [ignored]");
-#endif
-         ambitus_->suicide();
+         ambitus_->suicide ();
        }
     }
 }
 
-ENTER_DESCRIPTION(Ambitus_engraver,
+ENTER_DESCRIPTION (Ambitus_engraver,
 /* descr */       "",
 /* creats*/       "Ambitus",
 /* accepts */ "",