2 phrasing-slur-engraver.cc -- implement Phrasing_slur_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
12 #include "directional-element-interface.hh"
13 #include "international.hh"
14 #include "note-column.hh"
17 #include "stream-event.hh"
20 #include "translator.icc"
23 It is possible that a slur starts and ends on the same note. At
24 least, it is for phrasing slurs: a note can be both beginning and
32 This is largely similar to Slur_engraver. Check if fixes apply there too.
34 (on principle, engravers don't use inheritance for code sharing)
37 class Phrasing_slur_engraver
: public Engraver
39 Drul_array
<Stream_event
*> events_
;
40 Stream_event
*running_slur_start_
;
42 vector
<Grob
*> end_slurs_
;
45 void acknowledge_extra_object (Grob_info
);
46 DECLARE_ACKNOWLEDGER (accidental
);
47 DECLARE_ACKNOWLEDGER (fingering
);
48 DECLARE_ACKNOWLEDGER (note_column
);
49 DECLARE_ACKNOWLEDGER (slur
);
50 DECLARE_ACKNOWLEDGER (script
);
51 DECLARE_ACKNOWLEDGER (text_script
);
52 DECLARE_ACKNOWLEDGER (tie
);
53 DECLARE_ACKNOWLEDGER (tuplet_number
);
54 DECLARE_TRANSLATOR_LISTENER (phrasing_slur
);
56 void stop_translation_timestep ();
57 virtual void finalize ();
58 void process_music ();
61 TRANSLATOR_DECLARATIONS (Phrasing_slur_engraver
);
64 Phrasing_slur_engraver::Phrasing_slur_engraver ()
66 events_
[START
] = events_
[STOP
] = 0;
69 IMPLEMENT_TRANSLATOR_LISTENER (Phrasing_slur_engraver
, phrasing_slur
);
71 Phrasing_slur_engraver::listen_phrasing_slur (Stream_event
*ev
)
74 Let's not start more than one slur per moment.
76 Direction d
= to_dir (ev
->get_property ("span-direction"));
78 ASSIGN_EVENT_ONCE (events_
[START
], ev
);
79 else if (d
== STOP
&& !slurs_
.empty ())
80 ASSIGN_EVENT_ONCE (events_
[STOP
], ev
);
84 Phrasing_slur_engraver::acknowledge_note_column (Grob_info info
)
86 Grob
*e
= info
.grob ();
87 for (vsize i
= slurs_
.size (); i
--;)
88 Slur::add_column (slurs_
[i
], e
);
89 for (vsize i
= end_slurs_
.size (); i
--;)
90 Slur::add_column (end_slurs_
[i
], e
);
94 Phrasing_slur_engraver::acknowledge_extra_object (Grob_info info
)
96 Slur::auxiliary_acknowledge_extra_object (info
, slurs_
, end_slurs_
);
100 Phrasing_slur_engraver::acknowledge_accidental (Grob_info info
)
102 acknowledge_extra_object (info
);
106 Phrasing_slur_engraver::acknowledge_fingering (Grob_info info
)
108 acknowledge_extra_object (info
);
112 Phrasing_slur_engraver::acknowledge_text_script (Grob_info info
)
114 acknowledge_extra_object (info
);
118 Phrasing_slur_engraver::acknowledge_script (Grob_info info
)
120 if (!info
.grob ()->internal_has_interface (ly_symbol2scm ("dynamic-interface")))
121 acknowledge_extra_object (info
);
125 Phrasing_slur_engraver::acknowledge_tie (Grob_info info
)
127 acknowledge_extra_object (info
);
131 Phrasing_slur_engraver::acknowledge_tuplet_number (Grob_info info
)
133 acknowledge_extra_object (info
);
137 Phrasing_slur_engraver::acknowledge_slur (Grob_info info
)
139 acknowledge_extra_object (info
);
143 Phrasing_slur_engraver::finalize ()
146 slurs_
[0]->warning (_ ("unterminated phrasing slur"));
150 Phrasing_slur_engraver::process_music ()
158 if (events_
[START
] && slurs_
.empty ())
160 Stream_event
*ev
= events_
[START
];
162 Grob
*slur
= make_spanner ("PhrasingSlur", events_
[START
]->self_scm ());
163 Direction updown
= to_dir (ev
->get_property ("direction"));
165 set_grob_direction (slur
, updown
);
167 slurs_
.push_back (slur
);
172 Phrasing_slur_engraver::stop_translation_timestep ()
175 events_
[START
] = events_
[STOP
] = 0;
178 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, accidental
);
179 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, fingering
)
180 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, note_column
);
181 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, slur
);
182 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, script
);
183 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, text_script
);
184 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, tie
);
185 ADD_ACKNOWLEDGER (Phrasing_slur_engraver
, tuplet_number
);
187 ADD_TRANSLATOR (Phrasing_slur_engraver
,
189 "Print phrasing slurs. Similar to @ref{Slur_engraver}.",