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