]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/key-performer.cc
release: 1.1.0
[lilypond.git] / lily / key-performer.cc
index 0ed1f33afab5c2f24f05df44563cffb80bc8b5c8..3ccac03e21537a71d0b589984c1624838e53638c 100644 (file)
@@ -3,21 +3,21 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
+  (c)  1997--1998 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
 #include "key-performer.hh"
 #include "command-request.hh"
-#include "midi-item.hh"
+#include "audio-item.hh"
+
 
 
-IMPLEMENT_STATIC_NAME(Key_performer);
 IMPLEMENT_IS_TYPE_B1(Key_performer,Performer);
-ADD_THIS_PERFORMER(Key_performer);
+ADD_THIS_TRANSLATOR(Key_performer);
 
 Key_performer::Key_performer()
 {
-    key_req_l_ = 0;
+  key_req_l_ = 0;
 }
 
 Key_performer::~Key_performer()
@@ -28,38 +28,31 @@ void
 Key_performer::do_print() const
 {
 #ifndef NPRINT
-    if ( key_req_l_ )
-       key_req_l_->print();
+  if (key_req_l_)
+       key_req_l_->print();
 #endif
 }
 
 void
-Key_performer::process_requests()
+Key_performer::do_process_requests()
 {
-    if ( key_req_l_ ) {
-       int sharps_i = key_req_l_->sharps_i();
-       int flats_i = key_req_l_->flats_i();
-       // midi cannot handle non-conventional keys
-       if ( !( flats_i && sharps_i ) ) {
-           Midi_key k( sharps_i - flats_i, key_req_l_->minor_b() );
-           play_event( &k );
-       }
-       key_req_l_ = 0;
-    }
+  if (key_req_l_)
+       play (new Audio_key (key_req_l_));
+  key_req_l_ = 0;
 }
 
 bool
-Key_performer::try_request( Request* req_l )
+Key_performer::do_try_request (Request* req_l)
 {
-    if ( key_req_l_ )
+  if (key_req_l_)
        return false;
 
-    if ( req_l->command() )
-       key_req_l_ = req_l->command()->keychange();
-
-    if ( key_req_l_ )
-       return true;
+  if (dynamic_cast <Key_change_req *> (req_l))
+    {
+      key_req_l_ = dynamic_cast <Key_change_req*> (req_l);
+      return true;
+    }
 
-    return false;
+  return false;
 }