]> git.donarmstrong.com Git - lilypond.git/blob - lily/beam-performer.cc
427946738d4bc076dd8da9463fee88e812660504
[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--2004 Jan Nieuwenhuizen <janneke@gnu.org>
7  */
8
9 #include "performer.hh"
10 #include "event.hh"
11 #include "audio-item.hh"
12 #include "audio-column.hh"
13 #include "global-context.hh"
14 #include "warn.hh"
15
16 class Beam_performer : public Performer {
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 void 
32 Beam_performer::process_music ()
33 {
34   if (now_stop_ev_)
35     {
36       beam_ = false;
37     }
38
39   if (start_ev_)
40     {
41       beam_ = true;
42       set_melisma (true);
43     }
44 }
45
46
47 void
48 Beam_performer::set_melisma (bool ml)
49 {
50   SCM b = get_property ("autoBeaming");
51   if (!to_boolean (b))
52     daddy_context_->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F);
53 }
54
55 void
56 Beam_performer::start_translation_timestep ()
57 {
58   if (beam_)
59     {
60       set_melisma (true);
61     }
62   
63   start_ev_ = 0;
64   now_stop_ev_ = 0;
65 }
66  
67 bool
68 Beam_performer::try_music (Music *m)
69 {
70   if (m->is_mus_type ("beam-event"))
71     {
72       Direction d = to_dir (m->get_mus_property ("span-direction"));
73
74       if (d == START)
75         {
76           start_ev_ = m;
77         }
78       else if (d==STOP)
79         {
80           now_stop_ev_ = m;
81         }
82       return true;
83     }
84   return false;
85 }
86
87 ENTER_DESCRIPTION(Beam_performer,"","",
88                   "beam-event","","","");
89
90 Beam_performer::Beam_performer()
91 {
92   beam_ = false;
93 }