]> git.donarmstrong.com Git - lilypond.git/commitdiff
Small cleanups due to Han-Wen's comments.
authorJoe Neeman <joeneeman@gmail.com>
Thu, 21 Aug 2008 16:26:27 +0000 (09:26 -0700)
committerJoe Neeman <joeneeman@gmail.com>
Thu, 21 Aug 2008 16:26:27 +0000 (09:26 -0700)
input/regression/accidental-contemporary.ly
lily/accidental-engraver.cc
lily/context.cc
lily/include/context.hh
lily/scale.cc

index 145c96a9872e48bdb64382fbb21b9f198cbd579a..926c9ffc62328acf348ebaed52a5fdf4b1803b1a 100644 (file)
@@ -16,18 +16,31 @@ immediately repeated
 'neo-modern-cautionary style acts like neo-modern,
 adding cautionary parentheses around accidentals.
 @end itemize
+
+Both scores should show the same accidentals.
 "
 
 }
 
 \layout { ragged-right = ##t }
 
-\relative c'' {
-  #(set-accidental-style 'dodecaphonic)
-  gis4 a g gisis
-  #(set-accidental-style 'neo-modern)
-  gis8 a gis gis g' gis gis,, a'
-  #(set-accidental-style 'neo-modern-cautionary)
-  eis fis eis eis g2
+\score {
+  \relative c'' {
+    #(set-accidental-style 'dodecaphonic)
+    gis4 a g gisis
+    #(set-accidental-style 'neo-modern)
+    gis8 a gis gis g' gis gis,, a'
+    #(set-accidental-style 'neo-modern-cautionary)
+    eis fis eis eis g2
+  }
 }
 
+\score {
+  \relative c'' {
+    \set Staff.autoAccidentals = #'()
+    \set Staff.autoCautionaries = #'()
+    gis!4 a! g! gisis!
+    gis!8 a gis! gis g'! gis! gis,,! a'
+    eis! fis! eis? eis g?2
+  }
+}
index 4d8fbc06a10a182579d77edc57ba89d2c07f1ee1..f93fcca4657773273bbf2867a2ca34cc3dbf5415 100644 (file)
@@ -257,7 +257,7 @@ check_pitch_against_signature (SCM key_signature, Pitch const &pitch,
 // TODO: consider moving check_pitch_against_signature to SCM (in which case
 // we can delete this function).
 LY_DEFINE (ly_find_accidentals_simple, "ly:find-accidentals-simple", 5, 0, 0,
-          (SCM keysig, SCM pp, SCM barnum, SCM laziness, SCM octaveness ),
+          (SCM keysig, SCM pitch_scm, SCM barnum, SCM laziness, SCM octaveness ),
           "Checks the need for an accidental and a 'restore' accidental against a"
           " key signature.  The laziness is the number of bars for which reminder"
           " accidentals are used (ie. if laziness is zero, we only cancel accidentals"
@@ -266,7 +266,7 @@ LY_DEFINE (ly_find_accidentals_simple, "ly:find-accidentals-simple", 5, 0, 0,
           " 'any-octave and it specifies whether accidentals should be canceled in"
           " different octaves.")
 {
-  LY_ASSERT_TYPE (unsmob_pitch, pp, 2);
+  LY_ASSERT_TYPE (unsmob_pitch, pitch_scm, 2);
   LY_ASSERT_TYPE (scm_is_integer, barnum, 3);
   LY_ASSERT_TYPE (ly_is_symbol, octaveness, 5);
 
@@ -275,7 +275,7 @@ LY_DEFINE (ly_find_accidentals_simple, "ly:find-accidentals-simple", 5, 0, 0,
 
   SCM_ASSERT_TYPE (symbol_ok, octaveness, SCM_ARG5, __FUNCTION__, "'any-octave or 'same-octave");
 
-  Pitch * pitch = unsmob_pitch (pp);
+  Pitch *pitch = unsmob_pitch (pitch_scm);
 
   int bar_number = scm_to_int (barnum);
   bool ignore_octave = ly_symbol2scm ("any-octave") == octaveness; 
@@ -512,14 +512,8 @@ Accidental_engraver::stop_translation_timestep ()
       Rational a = pitch->get_alteration ();
       SCM key = scm_cons (scm_from_int (o), scm_from_int (n));
 
-      Duration *dur = unsmob_duration (note->get_property ("duration"));
-      Rational dur_length = dur ? dur->get_length () : Rational (0);
-      Moment mp = robust_scm2moment (get_property ("measurePosition"), Moment (0));
-
-      Moment end_mp = mp.grace_part_ < Rational(0)
-       ? Moment(mp.main_part_, mp.grace_part_ + dur_length)
-       : Moment(mp.main_part_ + dur_length, 0);
-
+      Moment end_mp = measure_position (context (),
+                                       unsmob_duration (note->get_property ("duration")));
       SCM position = scm_cons (scm_from_int (barnum), end_mp.smobbed_copy ());
 
       SCM localsig = SCM_EOL;
index 2f23024e2d9d8700f113881c9955547e9997fc89..c2c4a06f71a94093046da6a493066787538369e5 100644 (file)
@@ -709,6 +709,21 @@ measure_position (Context const *context)
   return m;
 }
 
+/* Finds the measure position after a note of length DUR that
+   begins at the current measure position. */
+Moment
+measure_position (Context const *context, Duration const *dur)
+{
+  Moment pos = measure_position (context);
+  Rational dur_length = dur ? dur->get_length () : Rational (0);
+
+  Moment end_pos = pos.grace_part_ < Rational(0)
+    ? Moment(pos.main_part_, pos.grace_part_ + dur_length)
+    : Moment(pos.main_part_ + dur_length, 0);
+
+  return end_pos;
+}
+
 int
 measure_number (Context const *context)
 {
index f0cd67c314e12e57f02d1a8caf7eb9083dcadf7c..9b58854dc8034d009d477e655b0a133233e0517b 100644 (file)
@@ -9,12 +9,13 @@
 #ifndef CONTEXT_HH
 #define CONTEXT_HH
 
+#include "duration.hh"
+#include "lily-proto.hh"
 #include "listener.hh"
 #include "moment.hh"
+#include "scm-hash.hh"
 #include "std-vector.hh"
 #include "virtual-methods.hh"
-#include "scm-hash.hh"
-#include "lily-proto.hh"
 
 class Context
 {
@@ -139,6 +140,7 @@ Grob *get_current_rest (Context *voice);
 DECLARE_UNSMOB (Context, context);
 
 Moment measure_position (Context const *context);
+Moment measure_position (Context const *context, Duration const *dur);
 Rational measure_length (Context const *context);
 int measure_number (Context const *context);
 void set_context_property_on_children (Context *trans, SCM sym, SCM val);
index 24abf335bc211daa7b731381edaec58535065df9..aa17285510e531d1823baa63a7d7fd87c0fee48a 100644 (file)
@@ -19,7 +19,7 @@
 LY_DEFINE (ly_make_scale, "ly:make-scale",
           1, 0, 0, (SCM steps),
           "Create a scale. "
-          "The argument is a vector of natural numbers, each of which "
+          "The argument is a vector of rational numbers, each of which "
           "represents the number of tones of a pitch above the tonic.")
 {
   bool type_ok = scm_is_vector (steps);