]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/key-performer.cc
release: 1.5.7
[lilypond.git] / lily / key-performer.cc
index d026cf590de28b1154b8605d79f8222ed652d540..e9454129248d817795e5f4f70be81748c3609f21 100644 (file)
@@ -3,15 +3,31 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--2000 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c)  1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
-#include "key-performer.hh"
+#include "lily-guile.hh"
 #include "command-request.hh"
 #include "audio-item.hh"
+#include "performer.hh"
 
-
-
+class Key_performer : public Performer
+{
+public:
+  VIRTUAL_COPY_CONS (Translator);
+  
+  Key_performer ();
+  ~Key_performer ();
+
+protected:
+  virtual bool try_music (Music* req_l);
+  virtual void create_audio_elements ();
+  virtual void stop_translation_timestep ();
+
+private:
+  Key_change_req* key_req_l_;
+  Audio_key* audio_p_;
+};
 
 ADD_THIS_TRANSLATOR (Key_performer);
 
@@ -25,21 +41,17 @@ Key_performer::~Key_performer ()
 {
 }
 
-void 
-Key_performer::do_print () const
-{
-#ifndef NPRINT
-  if (key_req_l_)
-    key_req_l_->print ();
-#endif
-}
-
 void
-Key_performer::do_process_requests ()
+Key_performer::create_audio_elements ()
 {
-  if (key_req_l_)
+  if (key_req_l_) 
     {
-      audio_p_ = new Audio_key (key_req_l_->key_);
+      SCM pitchlist = key_req_l_->get_mus_property ("pitch-alist");
+      SCM proc = scm_primitive_eval (ly_symbol2scm ("accidentals-in-key")); 
+      SCM acc = gh_call1 (proc, pitchlist);
+      proc = scm_primitive_eval (ly_symbol2scm ("major-key"));
+      SCM major = gh_call1 (proc, pitchlist);
+      audio_p_ = new Audio_key (gh_scm2int (acc), major == SCM_BOOL_T); 
       Audio_element_info info (audio_p_, key_req_l_);
       announce_element (info);
       key_req_l_ = 0;
@@ -47,7 +59,7 @@ Key_performer::do_process_requests ()
 }
 
 void
-Key_performer::do_pre_move_processing ()
+Key_performer::stop_translation_timestep ()
 {
   if (audio_p_)
     {
@@ -57,7 +69,7 @@ Key_performer::do_pre_move_processing ()
 }
 
 bool
-Key_performer::do_try_music (Music* req_l)
+Key_performer::try_music (Music* req_l)
 {
   if (Key_change_req *kc = dynamic_cast <Key_change_req *> (req_l))
     {