]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/key-performer.cc
* lily/modified-font-metric.cc (text_dimension): try
[lilypond.git] / lily / key-performer.cc
index 52d5f42e6cd901db1c5fcf62925b6364ccc3d6a8..92f8f16f6628ffe360de7e2c8369742dabd4f785 100644 (file)
@@ -3,20 +3,17 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2003 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 1997--2004 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
-#include "lily-guile.hh"
-
 #include "audio-item.hh"
 #include "performer.hh"
 #include "warn.hh"
 
-
 class Key_performer : public Performer
 {
 public:
-  TRANSLATOR_DECLARATIONS(Key_performer);
+  TRANSLATOR_DECLARATIONS (Key_performer);
   ~Key_performer ();
 
 protected:
@@ -44,33 +41,27 @@ Key_performer::create_audio_elements ()
 {
   if (key_req_) 
     {
-
-      /*
-       UGH. primitive-eval.
-       */
-      SCM pitchlist = key_req_->get_mus_property ("pitch-alist");
-      SCM proc = scm_primitive_eval (ly_symbol2scm ("accidentals-in-key")); 
-      SCM acc = gh_call1 (proc, pitchlist);
-      Pitch my_do (0, 
-                  gh_scm2int (ly_caar (pitchlist)),
-                  gh_scm2int (ly_cdar (pitchlist)));
+      SCM pitchlist = key_req_->get_property ("pitch-alist");
+      SCM proc = ly_lily_module_constant ("alterations-in-key");
+      
+      SCM acc = scm_call_1 (proc, pitchlist);
+      
+      Pitch key_do (0, 
+                   scm_to_int (scm_caar (pitchlist)),
+                   scm_to_int (scm_cdar (pitchlist)));
+
+      Pitch c_do (0, 0, 0);
                  
-      Pitch to_c (-1,
-                  (7 - gh_scm2int (ly_caar (pitchlist))) % 7,
-                  -gh_scm2int (ly_cdar (pitchlist)));
-
-      my_do = my_do.transposed (to_c);
-      to_c = my_do.transposed (Pitch(0,0,- my_do.get_alteration ()));
-
-      SCM c_pitchlist = ly_transpose_key_alist (pitchlist, to_c.smobbed_copy());
+      SCM c_pitchlist
+       = ly_transpose_key_alist (pitchlist,
+                                 pitch_interval (key_do, c_do).smobbed_copy ());
 
-      /*
-       MIDI keys are too limited for lilypond scales.
+      /* MIDI keys are too limited for lilypond scales.
+        We check for minor scale and assume major otherwise.  */
+      SCM minor = scm_c_eval_string ("minor");
+      audio_ = new Audio_key (scm_to_int (acc),
+                             SCM_BOOL_T != scm_equal_p (minor, c_pitchlist));
 
-       TODO: should probably detect minor key, though.
-      */
-      audio_ = new Audio_key (gh_scm2int (acc), true); 
       Audio_element_info info (audio_, key_req_);
       announce_element (info);
       key_req_ = 0;
@@ -102,7 +93,7 @@ Key_performer::try_music (Music* req)
   return false;
 }
 
-ENTER_DESCRIPTION(Key_performer,
+ADD_TRANSLATOR (Key_performer,
                  "","",
                  "key-change-event",
                  "","","");