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