]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/key-performer.cc
Fix some bugs in the dynamic engraver and PostScript backend
[lilypond.git] / lily / key-performer.cc
index 9c05a1bb4dc3eb20912a7579cc0f835bca3d35ee..26dbe93a8dec76763045dbb5d5b6c7d5f622e2bd 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 1997--2006 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "music-sequence.hh"
@@ -19,11 +19,11 @@ public:
 
 protected:
   virtual bool try_music (Music *ev);
-  virtual void create_audio_elements ();
-  virtual void stop_translation_timestep ();
+  void process_music ();
+  void stop_translation_timestep ();
 
 private:
-  Event *key_ev_;
+  Music *key_ev_;
   Audio_key *audio_;
 };
 
@@ -38,7 +38,7 @@ Key_performer::~Key_performer ()
 }
 
 void
-Key_performer::create_audio_elements ()
+Key_performer::process_music ()
 {
   if (key_ev_)
     {
@@ -59,9 +59,15 @@ Key_performer::create_audio_elements ()
 
       /* MIDI keys are too limited for lilypond scales.
         We check for minor scale and assume major otherwise.  */
-      SCM minor = scm_c_eval_string ("minor");
+
+      SCM third = scm_assoc (scm_from_int (2),
+                            c_pitchlist);
+      bool minor = (scm_is_pair (third)
+                   && scm_is_integer (scm_cdr (third))
+                   && scm_to_int (scm_cdr (third)) == FLAT);
+
       audio_ = new Audio_key (scm_to_int (acc),
-                             SCM_BOOL_T != scm_equal_p (minor, c_pitchlist));
+                             !minor);
 
       Audio_element_info info (audio_, key_ev_);
       announce_element (info);
@@ -82,19 +88,15 @@ Key_performer::stop_translation_timestep ()
 bool
 Key_performer::try_music (Music *ev)
 {
-  if (Event *kc = dynamic_cast<Event *> (ev))
-    {
-      if (key_ev_)
-       warning (_ ("FIXME: key change merge"));
+  if (!key_ev_)
+    key_ev_ = ev;
 
-      key_ev_ = kc;
-      return true;
-    }
-
-  return false;
+  return true;
 }
 
+#include "translator.icc"
+
 ADD_TRANSLATOR (Key_performer,
                "", "",
                "key-change-event",
-               "", "", "");
+               "", "");