2 piano-pedal-performer.cc -- implement Piano_pedal_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2006 Jan Nieuwenhuizen <janneke@gnu.org>
9 #include "performer.hh"
10 #include "audio-item.hh"
16 class Piano_pedal_performer : public Performer
22 Drul_array<Music *> event_drul_;
26 TRANSLATOR_DECLARATIONS (Piano_pedal_performer);
27 ~Piano_pedal_performer ();
30 virtual void initialize ();
31 virtual bool try_music (Music *);
32 void process_music ();
33 void stop_translation_timestep ();
34 void start_translation_timestep ();
37 Link_array<Audio_piano_pedal> audios_;
38 Pedal_info *info_alist_;
41 Piano_pedal_performer::Piano_pedal_performer ()
46 Piano_pedal_performer::~Piano_pedal_performer ()
52 Piano_pedal_performer::initialize ()
54 info_alist_ = new Pedal_info[4];
55 Pedal_info *p = info_alist_;
57 char *names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 };
62 p->event_drul_[START] = 0;
63 p->event_drul_[STOP] = 0;
72 Piano_pedal_performer::process_music ()
74 for (Pedal_info *p = info_alist_; p && p->name_; p++)
77 if (p->event_drul_[STOP])
80 p->event_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", String (p->name_)));
83 Audio_piano_pedal *a = new Audio_piano_pedal;
84 a->type_string_ = String (p->name_);
87 Audio_element_info info(a, p->event_drul_[STOP]);
88 announce_element (info);
93 if (p->event_drul_[START])
95 p->start_event_ = p->event_drul_[START];
96 Audio_piano_pedal *a = new Audio_piano_pedal;
97 a->type_string_ = String (p->name_);
100 Audio_element_info info(a, p->event_drul_[START]);
101 announce_element (info);
103 p->event_drul_[START] = 0;
104 p->event_drul_[STOP] = 0;
109 Piano_pedal_performer::stop_translation_timestep ()
111 for (int i = 0; i < audios_.size (); i++)
112 play_element (audios_[i]);
117 Piano_pedal_performer::start_translation_timestep ()
119 for (Pedal_info *p = info_alist_; p && p->name_; p++)
121 p->event_drul_[STOP] = 0;
122 p->event_drul_[START] = 0;
127 Piano_pedal_performer::try_music (Music *r)
129 if (r->is_mus_type ("pedal-event"))
131 for (Pedal_info *p = info_alist_; p->name_; p++)
133 String nm = p->name_ + String ("Event");
134 if (ly_is_equal (r->get_property ("name"),
135 scm_str2symbol (nm.to_str0 ())))
137 Direction d = to_dir (r->get_property ("span-direction"));
138 p->event_drul_[d] = r;
146 #include "translator.icc"
148 ADD_TRANSLATOR (Piano_pedal_performer, "", "",