]> git.donarmstrong.com Git - lilypond.git/blob - lily/melisma-translator.cc
new file.
[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 #include "engraver.hh"
11 #include "grob.hh"
12 #include "context.hh"
13
14 /**
15    Signal existence of melismas.
16  */
17 class Melisma_translator : public Translator
18 {
19 public:
20   TRANSLATOR_DECLARATIONS (Melisma_translator);
21 protected:
22   virtual bool try_music (Music *);
23   virtual void process_music ();
24   virtual void start_translation_timestep ();
25   Music * event_;
26 };
27
28
29 bool
30 Melisma_translator::try_music (Music *m) 
31 {
32   if (m->is_mus_type ("melisma-playing-event"))
33     {
34       return melisma_busy (context ());
35     }
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
60 void
61 Melisma_translator::start_translation_timestep ()
62 {
63   event_ = 0;
64 }
65   
66 Melisma_translator::Melisma_translator ()
67 {
68   event_ = 0;
69 }
70
71 ADD_TRANSLATOR (Melisma_translator,
72 /* descr */       "This translator collects melisma information about ties, beams, and user settings (@code{melismaBusy}, and signals it to the @code{\addlyrics} code.  ",
73 /* creats*/       "",
74 /* accepts */     "melisma-playing-event melisma-span-event",
75 /* acks  */      "",
76 /* reads */       "melismaBusy melismaBusyProperties slurMelismaBusy tieMelismaBusy beamMelismaBusy",
77 /* write */       "");