]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/accidental-engraver.cc
Merge branch 'master' of git://git.sv.gnu.org/lilypond
[lilypond.git] / lily / accidental-engraver.cc
index 5a15fbbd364a5d170524c3bb9cd1a101855f047f..c7eb79955a827f3061dce6d32d5c38a823cd8846 100644 (file)
@@ -67,6 +67,7 @@ protected:
 
   void stop_translation_timestep ();
   void process_acknowledged ();
+  
   virtual void finalize ();
   virtual void derived_mark () const;
 
@@ -150,18 +151,18 @@ recent_enough (int bar_number, SCM alteration_def, SCM laziness)
   return (bar_number <= scm_to_int (scm_cdr (alteration_def)) + scm_to_int (laziness));
 }
 
-static int
+static Rational
 extract_alteration (SCM alteration_def)
 {
   if (scm_is_number (alteration_def))
-    return scm_to_int (alteration_def);
+    return ly_scm2rational (alteration_def);
   else if (scm_is_pair (alteration_def))
-    return scm_to_int (scm_car (alteration_def));
+    return ly_scm2rational (scm_car (alteration_def));
   else if (alteration_def == SCM_BOOL_F)
-    return 0;
+    return Rational (0);
   else
     assert (0);
-  return 0;
+  return Rational (0);
 }
 
 bool
@@ -214,13 +215,13 @@ number_accidentals_from_sig (bool *different, SCM sig, Pitch *pitch,
     }
   else
     {
-      int prev = extract_alteration (previous_alteration);
-      int alter = pitch->get_alteration ();
+      Rational prev = extract_alteration (previous_alteration);
+      Rational alter = pitch->get_alteration ();
 
       if (alter == prev)
        num = 0;
-      else if ((abs (alter) < abs (prev)
-               || prev * alter < 0) && alter != 0)
+      else if ((alter.abs () < prev.abs ()
+               || (prev * alter).sign () < 0) && alter.sign ())
        num = 2;
       *different = (alter != prev);
     }
@@ -353,7 +354,6 @@ Accidental_engraver::process_acknowledged ()
              && !note->in_event_class ("trill-span-event"))
            create_accidental (&accidentals_[i], num > 1, cautionary);
 
-
          if (forced || cautionary)
            accidentals_[i].accidental_->set_property ("forced", SCM_BOOL_T);
        }
@@ -376,7 +376,7 @@ Accidental_engraver::create_accidental (Accidental_entry *entry,
   else
     a = make_standard_accidental (note, support, entry->origin_engraver_);
 
-  SCM accs = scm_cons (scm_from_int (pitch->get_alteration ()),
+  SCM accs = scm_cons (scm_from_int (pitch->get_alteration () * Rational (4)),
                       SCM_EOL);
   if (restore_natural)
     {
@@ -397,8 +397,8 @@ Accidental_engraver::make_standard_accidental (Stream_event *note,
                                               Grob *note_head,
                                               Engraver *trans)
 {
-
   (void)note;
+
   /*
     We construct the accidentals at the originating Voice
     level, so that we get the property settings for
@@ -440,6 +440,7 @@ Accidental_engraver::make_suggested_accidental (Stream_event *note,
                                                Engraver *trans)
 {
   (void) note;
+
   Grob *a = trans->make_item ("AccidentalSuggestion", note_head->self_scm ());
 
   Side_position_interface::add_support (a, note_head);
@@ -488,7 +489,7 @@ Accidental_engraver::stop_translation_timestep ()
 
       int n = pitch->get_notename ();
       int o = pitch->get_octave ();
-      int a = pitch->get_alteration ();
+      Rational a = pitch->get_alteration ();
       SCM key = scm_cons (scm_from_int (o), scm_from_int (n));
 
       SCM localsig = SCM_EOL;
@@ -514,7 +515,7 @@ Accidental_engraver::stop_translation_timestep ()
                noteheads with the same notename.
              */
              localsig = ly_assoc_front_x (localsig, key,
-                                          scm_cons (scm_from_int (a),
+                                          scm_cons (ly_rational2scm (a),
                                                     scm_from_int (barnum)));
              change = true;
            }
@@ -605,5 +606,6 @@ ADD_TRANSLATOR (Accidental_engraver,
                "internalBarNumber "
                "extraNatural "
                "harmonicAccidentals "
-               "localKeySignature",
-               "localKeySignature");
+               "localKeySignature ",
+               "localKeySignature "
+               );