X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fkey-performer.cc;h=327a53c042d50f0eeecd804a398c673a9294cea1;hb=5be4c57cff4ebd477b2b3d0899d6725794da77f0;hp=1b411a90e29952043fb55d3bf813378263976c91;hpb=978fa09436484d8d670e8ee8b3eb8cfacd493675;p=lilypond.git diff --git a/lily/key-performer.cc b/lily/key-performer.cc index 1b411a90e2..327a53c042 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--2009 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); void process_music (); void stop_translation_timestep (); + DECLARE_TRANSLATOR_LISTENER (key_change); private: - Music *key_ev_; + Stream_event *key_ev_; Audio_key *audio_; }; @@ -49,7 +52,7 @@ Key_performer::process_music () 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,8 +66,8 @@ Key_performer::process_music () 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); @@ -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; } -#include "translator.icc" - ADD_TRANSLATOR (Key_performer, - "", "", - "key-change-event", - "", ""); + /* doc */ + "", + + /* create */ + "", + + /* read */ + "", + + /* write */ + "" + );