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