]> git.donarmstrong.com Git - lilypond.git/blob - lily/melisma-translator.cc
adc873d4dcfa176cc746d3f6e44b88eb744edcc5
[lilypond.git] / lily / melisma-translator.cc
1 /*
2   melisma-engraver.cc -- implement Melisma_engraver
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1999--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "engraver.hh"
10 #include "grob.hh"
11 #include "context.hh"
12 #include "music.hh"
13 #include "translator.icc"
14
15 /* Remove this translator. */
16
17 /**
18    Signal existence of melismas.
19 */
20 class Melisma_translator : public Translator
21 {
22 public:
23   TRANSLATOR_DECLARATIONS (Melisma_translator);
24 protected:
25   virtual bool try_music (Music *);
26   void process_music ();
27   void start_translation_timestep ();
28   Music *event_;
29 };
30
31 bool
32 Melisma_translator::try_music (Music *m)
33 {
34   if (m->is_mus_type ("melisma-playing-event"))
35     return melisma_busy (context ());
36   else if (m->is_mus_type ("melisma-span-event"))
37     {
38       event_ = m;
39       return true;
40     }
41
42   return false;
43 }
44
45 void
46 Melisma_translator::process_music ()
47 {
48   if (event_)
49     {
50       SCM sd = event_->get_property ("span-direction");
51       Direction d = to_dir (sd);
52       if (d == START)
53         context ()->set_property ("melismaBusy", SCM_BOOL_T);
54       else
55         context ()->unset_property (ly_symbol2scm ("melismaBusy"));
56     }
57 }
58
59 void
60 Melisma_translator::start_translation_timestep ()
61 {
62   event_ = 0;
63 }
64
65 Melisma_translator::Melisma_translator ()
66 {
67   event_ = 0;
68 }
69
70 ADD_TRANSLATOR (Melisma_translator,
71                 /* doc */ "This translator collects melisma information about ties, beams, and user settings (@code{melismaBusy}, and signals it to the @code{\addlyrics} code.  ",
72                 /* create */ "",
73                 /* accept */ "",
74                 /* read */
75                 "beamMelismaBusy "
76                 "melismaBusy "
77                 "melismaBusyProperties "
78                 "slurMelismaBusy "
79                 "tieMelismaBusy "
80                 ,
81
82                 /* write */ "");