]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/new-accidental-engraver.cc
2003 -> 2004
[lilypond.git] / lily / new-accidental-engraver.cc
index 1e5fd92accd3140c8722d6ccfd55b1bce579f7eb..9b3d6a04ee3d9a83a2dcd0c4a4c21b0f333bc433 100644 (file)
@@ -1,16 +1,16 @@
 /*
   new-accidental-engraver.cc -- implement new_accidental_engraver
 
-  (c)  1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  Modified 2001--2002 by Rune Zedeler <rz@daimi.au.dk>
+  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  Modified 2001--2004 by Rune Zedeler <rz@daimi.au.dk>
 
   This is an experimental file - producing correct accidentals but
   unfortunately ruining the spacing. -rz
   
 */
 
-#include "musical-request.hh"
-#include "command-request.hh"
+#include "event.hh"
+
 #include "item.hh"
 #include "tie.hh"
 #include "rhythmic-head.hh"
@@ -64,7 +64,6 @@ protected:
   virtual void process_music ();
   virtual void acknowledge_grob (Grob_info);
   virtual void stop_translation_timestep ();
-  virtual void initialize ();
   virtual void process_acknowledged_grobs ();
   virtual void finalize ();
   virtual void process_grobs_first_pass ();
@@ -102,8 +101,8 @@ protected:
 
 New_accidental_engraver::New_accidental_engraver ()
 {
+  last_keysig_ = SCM_BOOL_F;
   accidental_placement_ = 0;
-  last_keysig_ = SCM_EOL;
 }
 
 /* inserts the source alist into the destination alist, erasing old entries.
@@ -167,13 +166,6 @@ static void set_property_on_family(Translator_group * trans, const char * sym, S
     }
 }
 
-void
-New_accidental_engraver::initialize ()
-{
-  // to ensure that process_music will initialize last_keysig_
-  last_keysig_ = SCM_BOOL_F;
-}
-
 /*
 calculates the number of accidentals on basis of the current local key sig
   (passed as argument)
@@ -185,9 +177,9 @@ static int
 number_accidentals (SCM sig, Music * note, Pitch *pitch, SCM curbarnum, SCM lazyness, 
                    bool ignore_octave_b)
 {
-  int n = pitch->notename_;
-  int o = pitch->octave_;
-  int a = pitch->alteration_;
+  int n = pitch->get_notename ();
+  int o = pitch->get_octave ();
+  int a = pitch->get_alteration (); 
   int curbarnum_i = gh_scm2int (curbarnum);
   int accbarnum_i = 0;
 
@@ -195,7 +187,7 @@ number_accidentals (SCM sig, Music * note, Pitch *pitch, SCM curbarnum, SCM lazy
   if (ignore_octave_b)
     prev = ly_assoc_cdr (gh_int2scm (n), sig);
   else
-    prev = gh_assoc (gh_cons (gh_int2scm (o), gh_int2scm (n)), sig);
+    prev = scm_assoc (gh_cons (gh_int2scm (o), gh_int2scm (n)), sig);
 
   /* should really be true unless prev == SCM_BOOL_F */
   if (gh_pair_p (prev) && gh_pair_p (ly_cdr (prev)))
@@ -207,7 +199,7 @@ number_accidentals (SCM sig, Music * note, Pitch *pitch, SCM curbarnum, SCM lazy
   /* If an accidental was not found or the accidental was too old */
   if (prev == SCM_BOOL_F ||
       (gh_number_p (lazyness) && curbarnum_i > accbarnum_i + gh_scm2int (lazyness)))
-    prev = gh_assoc (gh_int2scm (n), sig);
+    prev = scm_assoc (gh_int2scm (n), sig);
 
 
   SCM prev_acc = (prev == SCM_BOOL_F) ? gh_int2scm (0) : ly_cdr (prev);
@@ -270,14 +262,14 @@ number_accidentals (Music * note, Pitch *pitch, Translator_group * origin,
       */
       else if (gh_symbol_p (ly_car (accidentals)))
        {
-         String context = ly_symbol2string (ly_car (accidentals));
+         SCM context = ly_car (accidentals);
          
-         while (origin && !origin->is_alias_b (context))
+         while (origin && !origin->is_alias (context))
            origin = origin->daddy_trans_;
       
          if (!origin)
            warning (_f ("Symbol is not a parent context: %s. Ignored", 
-                        context.to_str0 ()));
+                        ly_symbol2string (context).to_str0 ()));
        }
       else warning (_f ("Accidental typesetting must be pair or context-name: %s", 
                        ly_scm2string (ly_car (accidentals)).to_str0 ()));
@@ -324,9 +316,9 @@ New_accidental_engraver::process_grobs_first_pass ()
       for (int j = 0; j < ties_.size (); j++)
        if (support == Tie::head (ties_[j], RIGHT))
          tie_changes = accidentals_[i].different_;
-      int n = pitch->notename_;
-      int o = pitch->octave_;
-      int a = pitch->alteration_;
+      int n = pitch->get_notename ();
+      int o = pitch->get_octave ();
+      int a = pitch->get_alteration ();
       SCM o_s = gh_int2scm (o);
       SCM n_s = gh_int2scm (n);
       SCM on_s = gh_cons (o_s,n_s);
@@ -421,12 +413,12 @@ New_accidental_engraver::process_grobs_second_pass ()
       
       if (num)
        {
-         Grob * a = new Item (get_property ("Accidental"));
+         Grob * a = make_item ("Accidental");
          a->set_parent (support, Y_AXIS);
          
          if (!accidental_placement_)
            {
-             accidental_placement_ = new Item (get_property ("AccidentalPlacement"));
+             accidental_placement_ = make_item ("AccidentalPlacement");
              announce_grob (accidental_placement_, a->self_scm());
            }
          
@@ -434,7 +426,7 @@ New_accidental_engraver::process_grobs_second_pass ()
          announce_grob (a, SCM_EOL);
          
          
-         SCM accs = gh_cons (gh_int2scm (pitch->alteration_), SCM_EOL);
+         SCM accs = gh_cons (gh_int2scm (pitch->get_alteration ()), SCM_EOL);
          if (num == 2 && extra_natural_b)
            accs = gh_cons (gh_int2scm (0), accs);
          
@@ -550,12 +542,12 @@ New_accidental_engraver::process_music ()
 
 
 ENTER_DESCRIPTION (New_accidental_engraver,
-"Make accidentals.  Catches note heads, ties and notices key-change
-events.  Due to interaction with ties (which don't come together
-with note heads), this needs to be in a context higher than Tie_engraver.",
+"Make accidentals.  Catches note heads, ties and notices key-change "
+"events.  Due to interaction with ties (which don't come together "
+"with note heads), this needs to be in a context higher than Tie_engraver.",
                   
               "Accidental",
-/* accepts */     "general-music",
+/* accepts */     "",
               "rhythmic-head-interface tie-interface arpeggio-interface",
               "localKeySignature localKeySignatureChanges extraNatural autoAccidentals autoCautionaries",
                   "localKeySignature localKeySignatureChanges");