]> git.donarmstrong.com Git - lilypond.git/blob - lily/beam-performer.cc
b5b694a04b052bb3308f91dc5a38fc5bf007564d
[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       set_melisma (false);
38     }
39
40   if (start_ev_)
41     {
42       beam_ = true;
43       set_melisma (true);
44     }
45 }
46
47
48 void
49 Beam_performer::set_melisma (bool ml)
50 {
51   SCM b = get_property ("autoBeaming");
52   if (!to_boolean (b))
53     daddy_context_->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T :SCM_BOOL_F);
54 }
55
56 void
57 Beam_performer::start_translation_timestep ()
58 {
59   start_ev_ = 0;
60   now_stop_ev_ = 0;
61 }
62  
63 bool
64 Beam_performer::try_music (Music *m)
65 {
66   if (m->is_mus_type ("beam-event"))
67     {
68       Direction d = to_dir (m->get_property ("span-direction"));
69
70       if (d == START)
71         {
72           start_ev_ = m;
73         }
74       else if (d==STOP)
75         {
76           now_stop_ev_ = m;
77         }
78       return true;
79     }
80   return false;
81 }
82
83 ENTER_DESCRIPTION (Beam_performer,"","",
84                   "beam-event","","","");
85
86 Beam_performer::Beam_performer ()
87 {
88   beam_ = false;
89 }