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