2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
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.
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.
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/>.
20 #include "engraver.hh"
23 #include "directional-element-interface.hh"
24 #include "international.hh"
25 #include "note-column.hh"
28 #include "stream-event.hh"
31 #include "translator.icc"
34 It is possible that a slur starts and ends on the same note. At
35 least, it is for phrasing slurs: a note can be both beginning and
43 This is largely similar to Slur_engraver. Check if fixes apply there too.
45 (on principle, engravers don't use inheritance for code sharing)
48 class Phrasing_slur_engraver
: public Engraver
50 Drul_array
<Stream_event
*> events_
;
51 Stream_event
*running_slur_start_
;
53 vector
<Grob
*> end_slurs_
;
56 void acknowledge_extra_object (Grob_info
);
57 DECLARE_ACKNOWLEDGER (accidental
);
58 DECLARE_ACKNOWLEDGER (fingering
);
59 DECLARE_ACKNOWLEDGER (note_column
);
60 DECLARE_ACKNOWLEDGER (slur
);
61 DECLARE_ACKNOWLEDGER (script
);
62 DECLARE_ACKNOWLEDGER (text_script
);
63 DECLARE_ACKNOWLEDGER (tie
);
64 DECLARE_ACKNOWLEDGER (tuplet_number
);
65 DECLARE_TRANSLATOR_LISTENER (phrasing_slur
);
67 void stop_translation_timestep ();
68 virtual void finalize ();
69 void process_music ();
72 TRANSLATOR_DECLARATIONS (Phrasing_slur_engraver
);
75 Phrasing_slur_engraver::Phrasing_slur_engraver ()
77 events_
[START
] = events_
[STOP
] = 0;
80 IMPLEMENT_TRANSLATOR_LISTENER (Phrasing_slur_engraver
, phrasing_slur
);
82 Phrasing_slur_engraver::listen_phrasing_slur (Stream_event
*ev
)
85 Let's not start more than one slur per moment.
87 Direction d
= to_dir (ev
->get_property ("span-direction"));
89 ASSIGN_EVENT_ONCE (events_
[START
], ev
);
90 else if (d
== STOP
&& !slurs_
.empty ())
91 ASSIGN_EVENT_ONCE (events_
[STOP
], ev
);
95 Phrasing_slur_engraver::acknowledge_note_column (Grob_info info
)
97 Grob
*e
= info
.grob ();
98 for (vsize i
= slurs_
.size (); i
--;)
99 Slur::add_column (slurs_
[i
], e
);
100 for (vsize i
= end_slurs_
.size (); i
--;)
101 Slur::add_column (end_slurs_
[i
], e
);
105 Phrasing_slur_engraver::acknowledge_extra_object (Grob_info info
)
107 Slur::auxiliary_acknowledge_extra_object (info
, slurs_
, end_slurs_
);
111 Phrasing_slur_engraver::acknowledge_accidental (Grob_info info
)
113 acknowledge_extra_object (info
);
117 Phrasing_slur_engraver::acknowledge_fingering (Grob_info info
)
119 acknowledge_extra_object (info
);
123 Phrasing_slur_engraver::acknowledge_text_script (Grob_info info
)
125 acknowledge_extra_object (info
);
129 Phrasing_slur_engraver::acknowledge_script (Grob_info info
)
131 if (!info
.grob ()->internal_has_interface (ly_symbol2scm ("dynamic-interface")))
132 acknowledge_extra_object (info
);
136 Phrasing_slur_engraver::acknowledge_tie (Grob_info info
)
138 acknowledge_extra_object (info
);
142 Phrasing_slur_engraver::acknowledge_tuplet_number (Grob_info info
)
144 acknowledge_extra_object (info
);
148 Phrasing_slur_engraver::acknowledge_slur (Grob_info info
)
150 acknowledge_extra_object (info
);
154 Phrasing_slur_engraver::finalize ()
157 slurs_
[0]->warning (_ ("unterminated phrasing slur"));
161 Phrasing_slur_engraver::process_music ()
169 if (events_
[START
] && slurs_
.empty ())
171 Stream_event
*ev
= events_
[START
];
173 Grob
*slur
= make_spanner ("PhrasingSlur", events_
[START
]->self_scm ());
174 Direction updown
= to_dir (ev
->get_property ("direction"));
176 set_grob_direction (slur
, updown
);
178 slurs_
.push_back (slur
);
183 Phrasing_slur_engraver::stop_translation_timestep ()
186 events_
[START
] = events_
[STOP
] = 0;
189 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, accidental
);
190 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, fingering
)
191 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, note_column
);
192 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, slur
);
193 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, script
);
194 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, text_script
);
195 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, tie
);
196 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, tuplet_number
);
198 ADD_TRANSLATOR (Phrasing_slur_engraver
,
200 "Print phrasing slurs. Similar to @ref{Slur_engraver}.",