]> git.donarmstrong.com Git - lilypond.git/blob - lily/lyric-performer.cc
release: 1.3.131
[lilypond.git] / lily / lyric-performer.cc
1 /*
2   lyric-performer.cc -- implement Lyric_performer
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "musical-request.hh"
10 #include "audio-item.hh"
11 #include "lily-proto.hh"
12 #include "performer.hh"
13 #include "array.hh"
14
15 class Lyric_performer : public Performer {
16 public:
17   VIRTUAL_COPY_CONS(Translator);
18  Lyric_performer ();
19
20 protected:
21
22   virtual bool try_music (Music* req_l);
23   virtual void stop_translation_timestep ();
24   virtual void create_audio_elements ();
25
26 private:
27   Link_array<Lyric_req> lreq_arr_;
28   Audio_text* audio_p_;
29 };
30
31 ADD_THIS_TRANSLATOR (Lyric_performer);
32
33 Lyric_performer::Lyric_performer ()
34 {
35   audio_p_ = 0;
36 }
37
38
39 void
40 Lyric_performer::create_audio_elements ()
41 {
42   // FIXME: won't work with fancy lyrics
43   if (lreq_arr_.size ()
44       && gh_string_p (lreq_arr_[0]->get_mus_property ("text"))
45       && ly_scm2string (lreq_arr_[0]->get_mus_property ("text")).length_i ())
46     {
47       audio_p_ = new Audio_text (Audio_text::LYRIC,
48                                  ly_scm2string (lreq_arr_[0]->get_mus_property ("text")));
49       Audio_element_info info (audio_p_, lreq_arr_[0]);
50       announce_element (info);
51     }
52   lreq_arr_.clear();
53 }
54
55 void
56 Lyric_performer::stop_translation_timestep ()
57 {
58   if (audio_p_)
59     {
60       play_element (audio_p_);
61       audio_p_ = 0;
62     }
63   lreq_arr_.clear();
64 }
65
66 bool
67 Lyric_performer::try_music (Music* req_l)
68 {
69   if (Lyric_req *lr = dynamic_cast <Lyric_req *> (req_l))
70     {
71       lreq_arr_.push (lr);
72       return true;
73     }
74   return false;
75 }
76