X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Flyric-performer.cc;h=fe5ca56d119670bda44b18c52c84d3e1b4f8f678;hb=d9b43b93f2c885409bafdb157138158f65cc49aa;hp=aa24dcac2501e7a34c7a57a32952ae7371a8d7ee;hpb=eeafd68c62481b0d10c292f0e4bfa5d821168c87;p=lilypond.git diff --git a/lily/lyric-performer.cc b/lily/lyric-performer.cc index aa24dcac25..fe5ca56d11 100644 --- a/lily/lyric-performer.cc +++ b/lily/lyric-performer.cc @@ -3,60 +3,74 @@ source file of the GNU LilyPond music typesetter - (c) 1997 Han-Wen Nienhuys - Jan Nieuwenhuizen + (c) 1997--2002 Jan Nieuwenhuizen */ -#include "lyric-performer.hh" #include "musical-request.hh" -//#include "text-item.hh" -//#include "paper-def.hh" -//#include "lookup.hh" +#include "audio-item.hh" +#include "lily-proto.hh" +#include "performer.hh" +#include "array.hh" +class Lyric_performer : public Performer { +public: + TRANSLATOR_DECLARATIONS(Lyric_performer); +protected: + + virtual bool try_music (Music* req_l); + virtual void stop_translation_timestep (); + virtual void create_audio_elements (); + +private: + Link_array lreq_arr_; + Audio_text* audio_p_; +}; -IMPLEMENT_STATIC_NAME(Lyric_performer); -IMPLEMENT_IS_TYPE_B1(Lyric_performer,Performer); -ADD_THIS_PERFORMER(Lyric_performer); -Lyric_performer::Lyric_performer() -{ -} -Lyric_performer::~Lyric_performer() + +Lyric_performer::Lyric_performer () { + audio_p_ = 0; } -bool -Lyric_performer::do_try_request( Request* req_l ) -{ - Musical_req* m_l = req_l->musical(); - if ( !m_l || ! m_l->lreq_l() ) - return false; - lreq_arr_.push( m_l->lreq_l() ); - return true; +void +Lyric_performer::create_audio_elements () +{ + // FIXME: won't work with fancy lyrics + if (lreq_arr_.size () + && gh_string_p (lreq_arr_[0]->get_mus_property ("text")) + && ly_scm2string (lreq_arr_[0]->get_mus_property ("text")).length_i ()) + { + audio_p_ = new Audio_text (Audio_text::LYRIC, + ly_scm2string (lreq_arr_[0]->get_mus_property ("text"))); + Audio_element_info info (audio_p_, lreq_arr_[0]); + announce_element (info); + } + lreq_arr_.clear (); } void -Lyric_performer::do_process_requests() +Lyric_performer::stop_translation_timestep () { -#if 0 - Text_item * last_item_l =0; - for (int i=0; i < lreq_arr_.size(); i++) { - Text_item *lp = new Text_item(lreq_arr_[i]->tdef_p_ ); - lp->dir_i_ = -1; - lp->fat_b_ = true; - if (last_item_l) - lp->add_support(last_item_l); - last_item_l = lp; - typeset_element(lp); + if (audio_p_) + { + play_element (audio_p_); + audio_p_ = 0; } -#endif + lreq_arr_.clear (); } -void -Lyric_performer::do_post_move_processing() +bool +Lyric_performer::try_music (Music* req_l) { - lreq_arr_.set_size(0); + if (Lyric_req *lr = dynamic_cast (req_l)) + { + lreq_arr_.push (lr); + return true; + } + return false; } +ENTER_DESCRIPTION(Lyric_performer,"","","","","");