X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;ds=sidebyside;f=lily%2Fpiano-pedal-performer.cc;h=ea4889f11bbeb1ec3ed6c506d3e407d3a54eaa2e;hb=aa23e460ca96734a29387c163e75db4f3980d13f;hp=675ed9140d1628f509bad4a3a846cd6b61185f9a;hpb=a6ee9dcd388111e842064a8d46ab06c4897a00d2;p=lilypond.git diff --git a/lily/piano-pedal-performer.cc b/lily/piano-pedal-performer.cc index 675ed9140d..ea4889f11b 100644 --- a/lily/piano-pedal-performer.cc +++ b/lily/piano-pedal-performer.cc @@ -3,40 +3,39 @@ source file of the GNU LilyPond music typesetter - (c) 2000 Jan Nieuwenhuizen + (c) 2000--2005 Jan Nieuwenhuizen */ #include "performer.hh" -#include "command-request.hh" -#include "musical-request.hh" #include "audio-item.hh" +#include "music.hh" /** perform Piano pedals - */ +*/ class Piano_pedal_performer : public Performer { struct Pedal_info { char const *name_; - Span_req* start_req_; - Drul_array req_l_drul_; + Music *start_event_; + Drul_array event_drul_; }; public: - TRANSLATOR_DECLARATIONS(Piano_pedal_performer); + TRANSLATOR_DECLARATIONS (Piano_pedal_performer); ~Piano_pedal_performer (); - + protected: virtual void initialize (); - virtual bool try_music (Music*); - virtual void create_audio_elements (); - virtual void stop_translation_timestep (); - virtual void start_translation_timestep (); + virtual bool try_music (Music *); + void process_music (); + void stop_translation_timestep (); + void start_translation_timestep (); private: Link_array audios_; - Pedal_info * info_alist_; + Pedal_info *info_alist_; }; Piano_pedal_performer::Piano_pedal_performer () @@ -55,59 +54,57 @@ Piano_pedal_performer::initialize () info_alist_ = new Pedal_info[4]; Pedal_info *p = info_alist_; - char * names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 }; - char **np = names ; + char *names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 }; + char **np = names; do { p->name_ = *np; - p->req_l_drul_[START] = 0; - p->req_l_drul_[STOP] = 0; - p->start_req_ = 0; + p->event_drul_[START] = 0; + p->event_drul_[STOP] = 0; + p->start_event_ = 0; p++; } - while (* (np ++)); + while (* (np++)); } void -Piano_pedal_performer::create_audio_elements () +Piano_pedal_performer::process_music () { - for (Pedal_info*p = info_alist_; p && p->name_; p ++) - + for (Pedal_info *p = info_alist_; p && p->name_; p++) + { - if (p->req_l_drul_[STOP]) + if (p->event_drul_[STOP]) { - if (!p->start_req_) - { - p->req_l_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", String (p->name_))); - } + if (!p->start_event_) + p->event_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", String (p->name_))); else { - Audio_piano_pedal* a = new Audio_piano_pedal; + Audio_piano_pedal *a = new Audio_piano_pedal; a->type_string_ = String (p->name_); a->dir_ = STOP; audios_.push (a); } - p->start_req_ = 0; + p->start_event_ = 0; } - if (p->req_l_drul_[START]) + if (p->event_drul_[START]) { - p->start_req_ = p->req_l_drul_[START]; - Audio_piano_pedal* a = new Audio_piano_pedal; + p->start_event_ = p->event_drul_[START]; + Audio_piano_pedal *a = new Audio_piano_pedal; a->type_string_ = String (p->name_); a->dir_ = START; audios_.push (a); } - p->req_l_drul_[START] = 0; - p->req_l_drul_[STOP] = 0; + p->event_drul_[START] = 0; + p->event_drul_[STOP] = 0; } } void Piano_pedal_performer::stop_translation_timestep () { - for (int i=0; i< audios_.size (); i++) + for (int i = 0; i < audios_.size (); i++) play_element (audios_[i]); audios_.clear (); } @@ -115,28 +112,35 @@ Piano_pedal_performer::stop_translation_timestep () void Piano_pedal_performer::start_translation_timestep () { - for (Pedal_info*p = info_alist_; p && p->name_; p ++) + for (Pedal_info *p = info_alist_; p && p->name_; p++) { - p->req_l_drul_[STOP] = 0; - p->req_l_drul_[START] = 0; + p->event_drul_[STOP] = 0; + p->event_drul_[START] = 0; } } bool -Piano_pedal_performer::try_music (Music* r) +Piano_pedal_performer::try_music (Music *r) { - if (Span_req * s = dynamic_cast (r)) + if (r->is_mus_type ("pedal-event")) { - for (Pedal_info*p = info_alist_; p->name_; p ++) + for (Pedal_info *p = info_alist_; p->name_; p++) { - if (scm_equal_p (s->get_mus_property ("span-type"), - ly_str02scm (p->name_)) == SCM_BOOL_T) + String nm = p->name_ + String ("Event"); + if (ly_is_equal (r->get_property ("name"), + scm_str2symbol (nm.to_str0 ()))) { - p->req_l_drul_[s->get_span_dir ()] = s; + Direction d = to_dir (r->get_property ("span-direction")); + p->event_drul_[d] = r; return true; } } } return false; } -ENTER_DESCRIPTION (Piano_pedal_performer, "","","","","" ); + +#include "translator.icc" + +ADD_TRANSLATOR (Piano_pedal_performer, "", "", + "pedal-event", + "", "");