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