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"
11 #include "audio-item.hh"
12 #include "international.hh"
18 class Piano_pedal_performer : public Performer
24 Drul_array<Music *> event_drul_;
28 TRANSLATOR_DECLARATIONS (Piano_pedal_performer);
29 ~Piano_pedal_performer ();
32 virtual void initialize ();
33 virtual bool try_music (Music *);
34 void process_music ();
35 void stop_translation_timestep ();
36 void start_translation_timestep ();
39 Link_array<Audio_piano_pedal> audios_;
40 Pedal_info *info_alist_;
43 Piano_pedal_performer::Piano_pedal_performer ()
48 Piano_pedal_performer::~Piano_pedal_performer ()
54 Piano_pedal_performer::initialize ()
56 info_alist_ = new Pedal_info[4];
57 Pedal_info *p = info_alist_;
59 char *names [] = { "Sostenuto", "Sustain", "UnaCorda", 0 };
64 p->event_drul_[START] = 0;
65 p->event_drul_[STOP] = 0;
74 Piano_pedal_performer::process_music ()
76 for (Pedal_info *p = info_alist_; p && p->name_; p++)
79 if (p->event_drul_[STOP])
82 p->event_drul_[STOP]->origin ()->warning (_f ("can't find start of piano pedal: `%s'", std::string (p->name_)));
85 Audio_piano_pedal *a = new Audio_piano_pedal;
86 a->type_string_ = std::string (p->name_);
88 audios_.push_back (a);
89 Audio_element_info info(a, p->event_drul_[STOP]);
90 announce_element (info);
95 if (p->event_drul_[START])
97 p->start_event_ = p->event_drul_[START];
98 Audio_piano_pedal *a = new Audio_piano_pedal;
99 a->type_string_ = std::string (p->name_);
101 audios_.push_back (a);
102 Audio_element_info info(a, p->event_drul_[START]);
103 announce_element (info);
105 p->event_drul_[START] = 0;
106 p->event_drul_[STOP] = 0;
111 Piano_pedal_performer::stop_translation_timestep ()
113 for (vsize i = 0; i < audios_.size (); i++)
114 play_element (audios_[i]);
119 Piano_pedal_performer::start_translation_timestep ()
121 for (Pedal_info *p = info_alist_; p && p->name_; p++)
123 p->event_drul_[STOP] = 0;
124 p->event_drul_[START] = 0;
129 Piano_pedal_performer::try_music (Music *r)
131 if (r->is_mus_type ("pedal-event"))
133 for (Pedal_info *p = info_alist_; p->name_; p++)
135 std::string nm = p->name_ + std::string ("Event");
136 if (ly_is_equal (r->get_property ("name"),
137 scm_str2symbol (nm.c_str ())))
139 Direction d = to_dir (r->get_property ("span-direction"));
140 p->event_drul_[d] = r;
148 #include "translator.icc"
150 ADD_TRANSLATOR (Piano_pedal_performer, "", "",