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