2 piano-pedal-performer.cc -- implement Piano_pedal_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2005 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "performer.hh"
10 #include "audio-item.hh"
15 class Piano_pedal_performer : public Performer
21 Drul_array<Music *> req_drul_;
25 TRANSLATOR_DECLARATIONS (Piano_pedal_performer);
26 ~Piano_pedal_performer ();
29 virtual void initialize ();
30 virtual bool try_music (Music *);
31 virtual void create_audio_elements ();
32 virtual void stop_translation_timestep ();
33 virtual void start_translation_timestep ();
36 Link_array<Audio_piano_pedal> audios_;
37 Pedal_info *info_alist_;
40 Piano_pedal_performer::Piano_pedal_performer ()
45 Piano_pedal_performer::~Piano_pedal_performer ()
51 Piano_pedal_performer::initialize ()
53 info_alist_ = new Pedal_info[4];
54 Pedal_info *p = info_alist_;
56 char *names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 };
61 p->req_drul_[START] = 0;
62 p->req_drul_[STOP] = 0;
71 Piano_pedal_performer::create_audio_elements ()
73 for (Pedal_info *p = info_alist_; p && p->name_; p++)
76 if (p->req_drul_[STOP])
80 p->req_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", String (p->name_)));
84 Audio_piano_pedal *a = new Audio_piano_pedal;
85 a->type_string_ = String (p->name_);
92 if (p->req_drul_[START])
94 p->start_req_ = p->req_drul_[START];
95 Audio_piano_pedal *a = new Audio_piano_pedal;
96 a->type_string_ = String (p->name_);
100 p->req_drul_[START] = 0;
101 p->req_drul_[STOP] = 0;
106 Piano_pedal_performer::stop_translation_timestep ()
108 for (int i = 0; i < audios_.size (); i++)
109 play_element (audios_[i]);
114 Piano_pedal_performer::start_translation_timestep ()
116 for (Pedal_info *p = info_alist_; p && p->name_; p++)
118 p->req_drul_[STOP] = 0;
119 p->req_drul_[START] = 0;
124 Piano_pedal_performer::try_music (Music *r)
126 if (r->is_mus_type ("pedal-event"))
128 for (Pedal_info *p = info_alist_; p->name_; p++)
130 String nm = p->name_ + String ("Event");
131 if (ly_c_equal_p (r->get_property ("name"),
132 scm_str2symbol (nm.to_str0 ())))
134 Direction d = to_dir (r->get_property ("span-direction"));
143 ADD_TRANSLATOR (Piano_pedal_performer, "", "",