]> git.donarmstrong.com Git - lilypond.git/blob - lily/beam-performer.cc
Run `make grand-replace'.
[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--2008 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 class Beam_performer : public Performer
19 {
20 public:
21   TRANSLATOR_DECLARATIONS (Beam_performer);
22
23 protected:
24   void start_translation_timestep ();
25   void process_music ();
26   void set_melisma (bool);
27   DECLARE_TRANSLATOR_LISTENER (beam);
28 private:
29   Stream_event *start_ev_;
30   Stream_event *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 IMPLEMENT_TRANSLATOR_LISTENER (Beam_performer, beam);
73 void
74 Beam_performer::listen_beam (Stream_event *ev)
75 {
76   Direction d = to_dir (ev->get_property ("span-direction"));
77
78   if (d == START)
79     start_ev_ = ev;
80   else if (d == STOP)
81     now_stop_ev_ = ev;
82 }
83
84 ADD_TRANSLATOR (Beam_performer,
85                 /* doc */
86                 "",
87
88                 /* create */
89                 "",
90
91                 /* read */
92                 "",
93
94                 /* write */
95                 ""
96                 );
97