X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Ftempo-performer.cc;h=34864274c48c044df84e2667939e0ece00270ec1;hb=d5e69ed8a1d37f6c43395c33b1481ded35afd4f9;hp=1f38e3a80950242fba35eb4ed38b4c5919a23bd7;hpb=c802622f935af83bb791ded58056428d6be31d0a;p=lilypond.git diff --git a/lily/tempo-performer.cc b/lily/tempo-performer.cc index 1f38e3a809..34864274c4 100644 --- a/lily/tempo-performer.cc +++ b/lily/tempo-performer.cc @@ -3,66 +3,77 @@ source file of the GNU LilyPond music typesetter - (c) 1997--2000 Jan Nieuwenhuizen + (c) 1997--2006 Jan Nieuwenhuizen */ -#include "tempo-performer.hh" -#include "command-request.hh" +#include "performer.hh" + #include "audio-item.hh" +#include "duration.hh" +#include "stream-event.hh" + +#include "translator.icc" + +class Tempo_performer : public Performer +{ +public: + TRANSLATOR_DECLARATIONS (Tempo_performer); + ~Tempo_performer (); + +protected: -ADD_THIS_TRANSLATOR (Tempo_performer); + virtual void derived_mark () const; + void stop_translation_timestep (); + void process_music (); +private: + Audio_tempo *audio_; + SCM last_tempo_; +}; + +void +Tempo_performer::derived_mark () const +{ + scm_gc_mark (last_tempo_); +} Tempo_performer::Tempo_performer () { - tempo_req_l_ = 0; - audio_p_ = 0; + last_tempo_ = SCM_EOL; + audio_ = 0; } Tempo_performer::~Tempo_performer () { } - void -Tempo_performer::do_process_music () +Tempo_performer::process_music () { - if (tempo_req_l_) + SCM w = get_property ("tempoWholesPerMinute"); + if (unsmob_moment (w) + && !ly_is_equal (w, last_tempo_)) { + Rational r = unsmob_moment (w)->main_part_; + r *= Rational (4, 1); - SCM met = tempo_req_l_->get_mus_property ("metronome-count"); - audio_p_ = new Audio_tempo (tempo_req_l_->dur_.length_mom () / - Moment (1, 4) - * Moment(gh_scm2int (met))); + audio_ = new Audio_tempo (r.to_int ()); - Audio_element_info info (audio_p_, tempo_req_l_); + Audio_element_info info (audio_, 0); announce_element (info); - tempo_req_l_ = 0; - } -} -void -Tempo_performer::do_pre_move_processing () -{ - if (audio_p_) - { - play_element (audio_p_); - audio_p_ = 0; + last_tempo_ = w; } } -bool -Tempo_performer::do_try_music (Music* req_l) +void +Tempo_performer::stop_translation_timestep () { - if (tempo_req_l_) - return false; - - if (Tempo_req *t = - dynamic_cast (req_l)) + if (audio_) { - tempo_req_l_ = t; - return true; + audio_ = 0; } - - return false; } +ADD_TRANSLATOR (Tempo_performer, "", "", + "tempoWholesPerMinute ", + "");