]> git.donarmstrong.com Git - lilypond.git/blob - lily/beam-performer.cc
* lily/include/translator.hh (class Translator): remove
[lilypond.git] / lily / beam-performer.cc
1 /*
2   beam-performer.cc -- implement Beam_performer
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1996--2005 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 "warn.hh"
14 #include "music.hh"
15
16 #include "translator.icc"
17
18 class Beam_performer : public Performer
19 {
20 public:
21   TRANSLATOR_DECLARATIONS (Beam_performer);
22
23 protected:
24   virtual bool try_music (Music *ev);
25   void start_translation_timestep ();
26   void process_music ();
27   void set_melisma (bool);
28 private:
29   Music *start_ev_;
30   Music *now_stop_ev_;
31   bool beam_;
32 };
33
34 Beam_performer::Beam_performer ()
35 {
36   beam_ = false;
37   start_ev_ = 0;
38   now_stop_ev_ = 0;
39 }
40
41 void
42 Beam_performer::process_music ()
43 {
44   if (now_stop_ev_)
45     {
46       beam_ = false;
47       set_melisma (false);
48     }
49
50   if (start_ev_)
51     {
52       beam_ = true;
53       set_melisma (true);
54     }
55 }
56
57 void
58 Beam_performer::set_melisma (bool ml)
59 {
60   SCM b = get_property ("autoBeaming");
61   if (!to_boolean (b))
62     context ()->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T : SCM_BOOL_F);
63 }
64
65 void
66 Beam_performer::start_translation_timestep ()
67 {
68   start_ev_ = 0;
69   now_stop_ev_ = 0;
70 }
71
72 bool
73 Beam_performer::try_music (Music *m)
74 {
75   if (m->is_mus_type ("beam-event"))
76     {
77       Direction d = to_dir (m->get_property ("span-direction"));
78
79       if (d == START)
80         {
81           start_ev_ = m;
82         }
83       else if (d == STOP)
84         {
85           now_stop_ev_ = m;
86         }
87       return true;
88     }
89   return false;
90 }
91
92 ADD_TRANSLATOR (Beam_performer, "", "",
93                 "beam-event", "",  "");
94