]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/scale.cc
update outdated comments
[lilypond.git] / lily / scale.cc
index b71f43fe207106a5d1a2171127642e9c1ddde937..ecd2b9357edb3a2ea4aec7c8ed10405c9008eb05 100644 (file)
@@ -3,39 +3,45 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 2006 Han-Wen Nienhuys <hanwen@lilypond.org>
+  (c) 2006--2007 Han-Wen Nienhuys <hanwen@lilypond.org>
   
 */
 
-#include  "pitch.hh"
+#include "scale.hh"
 
 #include "ly-smobs.icc"
 
+/*
+  todo: put string <-> pitch here too.
+
+*/
 LY_DEFINE (ly_make_scale, "ly:make-scale",
           1, 0, 0, (SCM steps),
           "Create a scale. Takes a vector of ints as argument")
 {
   bool type_ok = scm_is_vector (steps);
 
-  vector<int> semitones; 
+  vector<Rational> semitones; 
   if (type_ok)
     {
       int len = scm_c_vector_length (steps);
       for (int i = 0 ; i < len; i++)
        {
          SCM step = scm_c_vector_ref (steps, i);
-         type_ok = type_ok && scm_is_integer (step);
+         type_ok = type_ok && scm_is_rational (step);
          if (type_ok)
-           semitones.push_back (scm_to_int (step));
+           {
+             Rational from_c (scm_to_int (scm_numerator (step)),
+                              scm_to_int (scm_denominator (step)));
+             semitones.push_back (from_c);
+           }
        }
     }
-
   
   SCM_ASSERT_TYPE (type_ok, steps, SCM_ARG1, __FUNCTION__, "vector of int");
 
-
   Scale *s = new Scale;
-  s->step_semitones_ = semitones;
+  s->step_tones_ = semitones;
 
   SCM retval =  s->self_scm ();
 
@@ -60,9 +66,9 @@ LY_DEFINE (ly_set_default_scale, "ly:set-default-scale",
           1, 0, 0, (SCM scale),
           "Set the global default scale.")
 {
-  Scale *s = Scale::unsmob (scale);
-  SCM_ASSERT_TYPE (s, scale, SCM_ARG1, __FUNCTION__, "scale");
+  LY_ASSERT_SMOB (Scale, scale, 1);
 
+  Scale *s = Scale::unsmob (scale);
   if (default_global_scale)
     default_global_scale->unprotect ();
   default_global_scale = s;
@@ -96,7 +102,7 @@ Scale::Scale ()
 
 Scale::Scale (Scale const &src)
 {
-  step_semitones_ = src.step_semitones_;
+  step_tones_ = src.step_tones_;
   smobify_self ();
 }
 
@@ -105,5 +111,5 @@ Scale::~Scale ()
 {
 }
 
-IMPLEMENT_SMOBS(Scale);
-IMPLEMENT_DEFAULT_EQUAL_P(Scale);
+IMPLEMENT_SMOBS (Scale);
+IMPLEMENT_DEFAULT_EQUAL_P (Scale);