]> git.donarmstrong.com Git - lilypond.git/blob - lily/lyric-performer.cc
d759d4603ab9a6adf7e23e0db8a107d7088c3722
[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--2007 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "audio-item.hh"
10 #include "performer.hh"
11 #include "stream-event.hh"
12 #include "translator.icc"
13
14 class Lyric_performer : public Performer
15 {
16 public:
17   TRANSLATOR_DECLARATIONS (Lyric_performer);
18 protected:
19
20   void stop_translation_timestep ();
21   void process_music ();
22   DECLARE_TRANSLATOR_LISTENER (lyric);
23 private:
24   vector<Stream_event *> events_;
25   Audio_text *audio_;
26 };
27
28 Lyric_performer::Lyric_performer ()
29 {
30   audio_ = 0;
31 }
32
33 void
34 Lyric_performer::process_music ()
35 {
36   // FIXME: won't work with fancy lyrics
37   if (events_.size ()
38       && scm_is_string (events_[0]->get_property ("text"))
39       && ly_scm2string (events_[0]->get_property ("text")).length ())
40     {
41       audio_ = new Audio_text (Audio_text::LYRIC,
42                                ly_scm2string (events_[0]->get_property ("text")));
43       Audio_element_info info (audio_, events_[0]);
44       announce_element (info);
45     }
46   events_.clear ();
47 }
48
49 void
50 Lyric_performer::stop_translation_timestep ()
51 {
52   if (audio_)
53     {
54       audio_ = 0;
55     }
56   events_.clear ();
57 }
58
59 IMPLEMENT_TRANSLATOR_LISTENER (Lyric_performer, lyric);
60 void
61 Lyric_performer::listen_lyric (Stream_event *event)
62 {
63   events_.push_back (event);
64 }
65
66 ADD_TRANSLATOR (Lyric_performer,
67                 /* doc */
68                 "",
69
70                 /* create */
71                 "",
72
73                 /* read */
74                 "",
75
76                 /* write */
77                 ""
78                 );