]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/key-performer.cc
Run `make grand-replace'.
[lilypond.git] / lily / key-performer.cc
index 3f7cc6ac2fe1ffbbd9da30e273c89cdf9ae0d892..1f35d780c43f03eb6adcdd4137217d31f7ef873b 100644 (file)
@@ -3,14 +3,17 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997--2005 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 1997--2008 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
-#include "music-sequence.hh"
 #include "audio-item.hh"
+#include "music-sequence.hh"
 #include "performer.hh"
+#include "stream-event.hh"
 #include "warn.hh"
 
+#include "translator.icc"
+
 class Key_performer : public Performer
 {
 public:
@@ -18,12 +21,12 @@ public:
   ~Key_performer ();
 
 protected:
-  virtual bool try_music (Music *ev);
-  virtual void create_audio_elements ();
-  virtual void stop_translation_timestep ();
+  void process_music ();
+  void stop_translation_timestep ();
 
+  DECLARE_TRANSLATOR_LISTENER (key_change);
 private:
-  Music *key_ev_;
+  Stream_event *key_ev_;
   Audio_key *audio_;
 };
 
@@ -38,7 +41,7 @@ Key_performer::~Key_performer ()
 }
 
 void
-Key_performer::create_audio_elements ()
+Key_performer::process_music ()
 {
   if (key_ev_)
     {
@@ -49,7 +52,7 @@ Key_performer::create_audio_elements ()
 
       Pitch key_do (0,
                    scm_to_int (scm_caar (pitchlist)),
-                   scm_to_int (scm_cdar (pitchlist)));
+                   ly_scm2rational (scm_cdar (pitchlist)));
 
       Pitch c_do (0, 0, 0);
 
@@ -63,12 +66,12 @@ Key_performer::create_audio_elements ()
       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);
-      
+                   && scm_is_number (scm_cdr (third))
+                   && ly_scm2rational (scm_cdr (third)) == FLAT_ALTERATION);
+
       audio_ = new Audio_key (scm_to_int (acc),
                              !minor);
-                   
+
       Audio_element_info info (audio_, key_ev_);
       announce_element (info);
       key_ev_ = 0;
@@ -80,23 +83,28 @@ Key_performer::stop_translation_timestep ()
 {
   if (audio_)
     {
-      play_element (audio_);
       audio_ = 0;
     }
 }
 
-bool
-Key_performer::try_music (Music *ev)
+IMPLEMENT_TRANSLATOR_LISTENER (Key_performer, key_change);
+void
+Key_performer::listen_key_change (Stream_event *ev)
 {
   if (!key_ev_)
-    {
-      key_ev_ = ev;
-    }
-      
-  return true;
+    key_ev_ = ev;
 }
 
 ADD_TRANSLATOR (Key_performer,
-               "", "",
-               "key-change-event",
-               "", "", "");
+               /* doc */
+               "",
+
+               /* create */
+               "",
+
+               /* read */
+               "",
+
+               /* write */
+               ""
+               );