X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fkey-performer.cc;h=32f94a632ed1356aaa48394432237f901ce9d28c;hb=1cdc9680f2094525103d335d80bc3950f918ed03;hp=9443d33eff0cf2d580cd36a7d413a9bd6c227a63;hpb=e837c7556a0a39cbb7a6d948ffa7101d22df1f33;p=lilypond.git diff --git a/lily/key-performer.cc b/lily/key-performer.cc index 9443d33eff..32f94a632e 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 (); - virtual void stop_translation_timestep (); + void process_music (); + void stop_translation_timestep (); + DECLARE_TRANSLATOR_LISTENER (key_change); private: - Event *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,28 +83,20 @@ 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 (Event *kc = dynamic_cast (ev)) - { - if (!key_ev_) - { - key_ev_ = kc; - } - - return true; - } - - return false; + if (!key_ev_) + key_ev_ = ev; } ADD_TRANSLATOR (Key_performer, - "", "", - "key-change-event", - "", "", ""); + "", + "", + "", + "");