]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/pitch.cc
* input/test/spanner-after-break-tweak.ly: import
[lilypond.git] / lily / pitch.cc
index 4d1096fcc6fdd7aadc334da651d1ebef25667f6f..895f18ef6265fe5c80308d044134e12d533fe86e 100644 (file)
@@ -18,15 +18,6 @@ Pitch::Pitch (int o, int n, int a)
   notename_ = n;
   alteration_ = a;
   octave_ = o;
-
-  if (n < 0 || n >= 7 ||
-      a < -2 || a > 2)
-    {
-      String s = _ ("Pitch arguments out of range");
-      s += ": alteration = " + to_string (a);
-      s += ", notename = " + to_string (n);
-      warning (s);
-    }
   normalise ();
 }
 
@@ -154,10 +145,10 @@ interval (Pitch const & from , Pitch const & to )
 char const *accname[] = {"eses", "es", "", "is" , "isis"};
 
 String
-Pitch::string () const
+Pitch::to_string () const
 {
   int n = (notename_ + 2) % 7;
-  String s = to_string (char (n + 'a'));
+  String s = ::to_string (char (n + 'a'));
   if (alteration_)
     s += String (accname[alteration_ + 2]);
 
@@ -171,7 +162,7 @@ Pitch::string () const
     {
       int o = (-octave_) - 1;
       while (o--)
-       s += to_string (',');
+       s += ::to_string (',');
     }
 
   return s;
@@ -257,7 +248,7 @@ Pitch::print_smob (SCM s, SCM port, scm_print_state *)
   Pitch  *r = (Pitch *) ly_cdr (s);
      
   scm_puts ("#<Pitch ", port);
-  scm_display (scm_makfrom0str (r->string ().to_str0 ()), port);
+  scm_display (scm_makfrom0str (r->to_string ().to_str0 ()), port);
   scm_puts (" >", port);
   
   return 1;
@@ -366,9 +357,35 @@ LY_DEFINE(pitch_semitones,  "ly:pitch-semitones", 1, 0, 0,
 LY_DEFINE(pitch_less, "ly:pitch<?", 2,0,0, (SCM p1, SCM p2),
          "Is @var{p1} lower than @var{p2}? This uses lexicographic ordening.")
 {
-  return Pitch::less_p (ly_car (p1),  ly_car (p2));
+  Pitch *a = unsmob_pitch (p1);
+  Pitch *b = unsmob_pitch (p2);
+  
+  SCM_ASSERT_TYPE(a, p1, SCM_ARG1, __FUNCTION__, "Pitch");
+  SCM_ASSERT_TYPE(b, p2, SCM_ARG2, __FUNCTION__, "Pitch");
+
+  if (Pitch::compare (*a, *b) < 0)
+    return SCM_BOOL_T;
+  else
+    return SCM_BOOL_F;
+}
+
+LY_DEFINE(ly_pitch_diff, "ly:pitch-diff", 2 ,0 ,0,
+         (SCM pitch, SCM  root),
+         "Return pitch with value DELTA =  PITCH - ROOT, ie, "
+"ROOT == (ly:pitch-transpose root delta).")
+{
+  Pitch *p = unsmob_pitch (pitch);
+  Pitch *r = unsmob_pitch (root);
+  SCM_ASSERT_TYPE(p, pitch, SCM_ARG1, __FUNCTION__, "Pitch");
+  SCM_ASSERT_TYPE(r, root, SCM_ARG2, __FUNCTION__, "Pitch");
+
+  return interval (*r,  *p).smobbed_copy();
 }
 
+         
+
+
+
 SCM
 Pitch::smobbed_copy ()const
 {