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