]> git.donarmstrong.com Git - lilypond.git/blob - lily/lyric-performer.cc
*** empty log message ***
[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--2005 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "audio-item.hh"
10 #include "performer.hh"
11
12 class Lyric_performer : public Performer {
13 public:
14   TRANSLATOR_DECLARATIONS (Lyric_performer);
15 protected:
16
17   virtual bool try_music (Music* req);
18   virtual void stop_translation_timestep ();
19   virtual void create_audio_elements ();
20
21 private:
22   Link_array<Music> lreqs_;
23   Audio_text* audio_;
24 };
25
26
27
28
29 Lyric_performer::Lyric_performer ()
30 {
31   audio_ = 0;
32 }
33
34
35 void
36 Lyric_performer::create_audio_elements ()
37 {
38   // FIXME: won't work with fancy lyrics
39   if (lreqs_.size ()
40       && scm_is_string (lreqs_[0]->get_property ("text"))
41       && ly_scm2string (lreqs_[0]->get_property ("text")).length ())
42     {
43       audio_ = new Audio_text (Audio_text::LYRIC,
44                                  ly_scm2string (lreqs_[0]->get_property ("text")));
45       Audio_element_info info (audio_, lreqs_[0]);
46       announce_element (info);
47     }
48   lreqs_.clear ();
49 }
50
51 void
52 Lyric_performer::stop_translation_timestep ()
53 {
54   if (audio_)
55     {
56       play_element (audio_);
57       audio_ = 0;
58     }
59   lreqs_.clear ();
60 }
61
62 bool
63 Lyric_performer::try_music (Music* req)
64 {
65   if (req->is_mus_type ("lyric-event"))
66     {
67       lreqs_.push (req);
68       return true;
69     }
70   return false;
71 }
72
73 ADD_TRANSLATOR (Lyric_performer,"","","lyric-event","","","");