]> git.donarmstrong.com Git - lilypond.git/blob - lily/slur-performer.cc
01fdb326153e0caf27c35da33e4dddb68fe304c4
[lilypond.git] / lily / slur-performer.cc
1 /*
2   slur-performer.cc -- implement Slur_performer
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996--2007 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "performer.hh"
10 #include "audio-item.hh"
11 #include "audio-column.hh"
12 #include "global-context.hh"
13 #include "stream-event.hh"
14 #include "warn.hh"
15
16 #include "translator.icc"
17
18 /*
19   this is C&P from beam_performer.
20 */
21
22 class Slur_performer : public Performer
23 {
24 public:
25   TRANSLATOR_DECLARATIONS (Slur_performer);
26
27 protected:
28   void start_translation_timestep ();
29   void process_music ();
30   void set_melisma (bool);
31   
32   DECLARE_TRANSLATOR_LISTENER (slur);
33 private:
34   Stream_event *start_ev_;
35   Stream_event *now_stop_ev_;
36   bool slur_;
37 };
38
39 Slur_performer::Slur_performer ()
40 {
41   slur_ = false;
42   start_ev_ = 0;
43   now_stop_ev_ = 0;
44 }
45
46 void
47 Slur_performer::process_music ()
48 {
49   if (now_stop_ev_)
50     {
51       slur_ = false;
52       set_melisma (false);
53     }
54
55   if (start_ev_)
56     {
57       slur_ = true;
58       set_melisma (true);
59     }
60 }
61
62 void
63 Slur_performer::set_melisma (bool ml)
64 {
65   context ()->set_property ("slurMelismaBusy", ml ? SCM_BOOL_T : SCM_BOOL_F);
66 }
67
68 void
69 Slur_performer::start_translation_timestep ()
70 {
71   start_ev_ = 0;
72   now_stop_ev_ = 0;
73 }
74
75 IMPLEMENT_TRANSLATOR_LISTENER (Slur_performer, slur);
76 void
77 Slur_performer::listen_slur (Stream_event *ev)
78 {
79   Direction d = to_dir (ev->get_property ("span-direction"));
80
81   if (d == START)
82     start_ev_ = ev;
83   else if (d == STOP)
84     now_stop_ev_ = ev;
85 }
86
87 ADD_TRANSLATOR (Slur_performer,
88                 /* doc */
89                 "",
90
91                 /* create */
92                 "",
93
94                 /* read */
95                 "",
96
97                 /* write */
98                 ""
99                 );