]> git.donarmstrong.com Git - lilypond.git/blob - lily/slur-performer.cc
Web-ja: update introduction
[lilypond.git] / lily / slur-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 /*
30   this is C&P from beam_performer.
31 */
32
33 class Slur_performer : public Performer
34 {
35 public:
36   TRANSLATOR_DECLARATIONS (Slur_performer);
37
38 protected:
39   void start_translation_timestep ();
40   void process_music ();
41   void set_melisma (bool);
42
43   void listen_slur (Stream_event *);
44 private:
45   Stream_event *start_ev_;
46   Stream_event *now_stop_ev_;
47   bool slur_;
48 };
49
50 Slur_performer::Slur_performer (Context *c)
51   : Performer (c)
52 {
53   slur_ = false;
54   start_ev_ = 0;
55   now_stop_ev_ = 0;
56 }
57
58 void
59 Slur_performer::process_music ()
60 {
61   if (now_stop_ev_)
62     {
63       slur_ = false;
64       set_melisma (false);
65     }
66
67   if (start_ev_)
68     {
69       slur_ = true;
70       set_melisma (true);
71     }
72 }
73
74 void
75 Slur_performer::set_melisma (bool ml)
76 {
77   context ()->set_property ("slurMelismaBusy", ml ? SCM_BOOL_T : SCM_BOOL_F);
78 }
79
80 void
81 Slur_performer::start_translation_timestep ()
82 {
83   start_ev_ = 0;
84   now_stop_ev_ = 0;
85 }
86
87 void
88 Slur_performer::listen_slur (Stream_event *ev)
89 {
90   Direction d = to_dir (ev->get_property ("span-direction"));
91
92   if (d == START)
93     start_ev_ = ev;
94   else if (d == STOP)
95     now_stop_ev_ = ev;
96 }
97
98 void
99 Slur_performer::boot ()
100 {
101   ADD_LISTENER (Slur_performer, slur);
102 }
103
104 ADD_TRANSLATOR (Slur_performer,
105                 /* doc */
106                 "",
107
108                 /* create */
109                 "",
110
111                 /* read */
112                 "",
113
114                 /* write */
115                 ""
116                );