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