2 piano-pedal-performer.cc -- implement Piano_pedal_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2004 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "performer.hh"
12 #include "audio-item.hh"
17 class Piano_pedal_performer : public Performer
23 Drul_array<Music*> req_l_drul_;
27 TRANSLATOR_DECLARATIONS (Piano_pedal_performer);
28 ~Piano_pedal_performer ();
31 virtual void initialize ();
32 virtual bool try_music (Music*);
33 virtual void create_audio_elements ();
34 virtual void stop_translation_timestep ();
35 virtual void start_translation_timestep ();
38 Link_array<Audio_piano_pedal> audios_;
39 Pedal_info * info_alist_;
42 Piano_pedal_performer::Piano_pedal_performer ()
47 Piano_pedal_performer::~Piano_pedal_performer ()
53 Piano_pedal_performer::initialize ()
55 info_alist_ = new Pedal_info[4];
56 Pedal_info *p = info_alist_;
58 char * names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 };
63 p->req_l_drul_[START] = 0;
64 p->req_l_drul_[STOP] = 0;
73 Piano_pedal_performer::create_audio_elements ()
75 for (Pedal_info*p = info_alist_; p && p->name_; p ++)
78 if (p->req_l_drul_[STOP])
82 p->req_l_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", String (p->name_)));
86 Audio_piano_pedal* a = new Audio_piano_pedal;
87 a->type_string_ = String (p->name_);
94 if (p->req_l_drul_[START])
96 p->start_req_ = p->req_l_drul_[START];
97 Audio_piano_pedal* a = new Audio_piano_pedal;
98 a->type_string_ = String (p->name_);
102 p->req_l_drul_[START] = 0;
103 p->req_l_drul_[STOP] = 0;
108 Piano_pedal_performer::stop_translation_timestep ()
110 for (int i=0; i< audios_.size (); i++)
111 play_element (audios_[i]);
116 Piano_pedal_performer::start_translation_timestep ()
118 for (Pedal_info*p = info_alist_; p && p->name_; p ++)
120 p->req_l_drul_[STOP] = 0;
121 p->req_l_drul_[START] = 0;
126 Piano_pedal_performer::try_music (Music* r)
128 if (r->is_mus_type ("pedal-event"))
130 for (Pedal_info*p = info_alist_; p->name_; p ++)
132 String nm = p->name_ + String ("Event");
133 if (ly_c_equal_p (r->get_property ("name") ,
134 scm_str2symbol (nm.to_str0())))
136 Direction d = to_dir (r->get_property ("span-direction"));
137 p->req_l_drul_[d] = r;
145 ENTER_DESCRIPTION (Piano_pedal_performer, "","",