]> git.donarmstrong.com Git - lilypond.git/blob - lily/beam-performer.cc
Web-ja: update introduction
[lilypond.git] / lily / beam-performer.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1996--2015 Jan Nieuwenhuizen <janneke@gnu.org>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "performer.hh"
21 #include "audio-item.hh"
22 #include "audio-column.hh"
23 #include "global-context.hh"
24 #include "stream-event.hh"
25 #include "warn.hh"
26
27 #include "translator.icc"
28
29 class Beam_performer : public Performer
30 {
31 public:
32   TRANSLATOR_DECLARATIONS (Beam_performer);
33
34 protected:
35   void start_translation_timestep ();
36   void process_music ();
37   void set_melisma (bool);
38   void listen_beam (Stream_event *);
39 private:
40   Stream_event *start_ev_;
41   Stream_event *now_stop_ev_;
42   bool beam_;
43 };
44
45 Beam_performer::Beam_performer (Context *c)
46   : Performer (c)
47 {
48   beam_ = false;
49   start_ev_ = 0;
50   now_stop_ev_ = 0;
51 }
52
53 void
54 Beam_performer::process_music ()
55 {
56   if (now_stop_ev_)
57     {
58       beam_ = false;
59       set_melisma (false);
60     }
61
62   if (start_ev_)
63     {
64       beam_ = true;
65       set_melisma (true);
66     }
67 }
68
69 void
70 Beam_performer::set_melisma (bool ml)
71 {
72   SCM b = get_property ("autoBeaming");
73   if (!to_boolean (b))
74     context ()->set_property ("beamMelismaBusy", ml ? SCM_BOOL_T : SCM_BOOL_F);
75 }
76
77 void
78 Beam_performer::start_translation_timestep ()
79 {
80   start_ev_ = 0;
81   now_stop_ev_ = 0;
82 }
83
84 void
85 Beam_performer::listen_beam (Stream_event *ev)
86 {
87   Direction d = to_dir (ev->get_property ("span-direction"));
88
89   if (d == START)
90     start_ev_ = ev;
91   else if (d == STOP)
92     now_stop_ev_ = ev;
93 }
94
95 void
96 Beam_performer::boot ()
97 {
98   ADD_LISTENER (Beam_performer, beam);
99 }
100
101 ADD_TRANSLATOR (Beam_performer,
102                 /* doc */
103                 "",
104
105                 /* create */
106                 "",
107
108                 /* read */
109                 "",
110
111                 /* write */
112                 ""
113                );
114