]> git.donarmstrong.com Git - lilypond.git/blob - lily/beam-performer.cc
*** empty log message ***
[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 "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 public:
17   TRANSLATOR_DECLARATIONS (Beam_performer);
18   
19 protected:
20   virtual bool try_music (Music *ev) ;
21   virtual void start_translation_timestep ();
22   virtual void process_music ();
23   void set_melisma (bool);
24 private:
25   Music *start_ev_;
26   Music *now_stop_ev_;
27   bool beam_;
28 };
29
30 Beam_performer::Beam_performer ()
31 {
32   beam_ = false;
33   start_ev_ = 0;
34   now_stop_ev_ = 0;
35 }
36
37 void 
38 Beam_performer::process_music ()
39 {
40   if (now_stop_ev_)
41     {
42       beam_ = false;
43       set_melisma (false);
44     }
45
46   if (start_ev_)
47     {
48       beam_ = true;
49       set_melisma (true);
50     }
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 ENTER_DESCRIPTION (Beam_performer,"","",
90                   "beam-event","","","");
91