X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fkey-performer.cc;h=8a12e9bcf5f00b325f3dca5945b56ebba346b6ee;hb=357b40db408f9809079d831ff05ebef956dd73d7;hp=d28c62fcc9409645ac54be58bac1968c8b077df1;hpb=7f6816438d66f6d70db5b68454d80656a0f3f131;p=lilypond.git diff --git a/lily/key-performer.cc b/lily/key-performer.cc index d28c62fcc9..8a12e9bcf5 100644 --- a/lily/key-performer.cc +++ b/lily/key-performer.cc @@ -3,14 +3,17 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2005 Jan Nieuwenhuizen + (c) 1997--2007 Jan Nieuwenhuizen */ -#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 (); + 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,25 +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; } -#include "translator.icc" - ADD_TRANSLATOR (Key_performer, - "", "", - "key-change-event", - "", ""); + /* doc */ + "", + + /* create */ + "", + + /* read */ + "", + + /* write */ + "" + );