2
beam-engraver.cc -- implement Beam_engraver
2
beam-engraver.cc -- implement Beam_engraver
4
4
source file of the GNU LilyPond music typesetter
6
(c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10
#include "engraver.hh"
6
(c) 1998--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
15
10
#include "beaming.hh"
16
#include "score-engraver.hh"
18
12
#include "drul-array.hh"
13
#include "duration.hh"
14
#include "engraver.hh"
15
#include "international.hh"
18
#include "score-engraver.hh"
20
19
#include "spanner.hh"
23
#include "translator.icc"
23
25
class Beam_engraver : public Engraver
28
DECLARE_ACKNOWLEDGER (stem);
29
DECLARE_ACKNOWLEDGER (rest);
28
33
Spanner *finished_beam_;
30
Music * prev_start_ev_;
34
Beaming_info_list * beam_info_;
35
Beaming_info_list * finished_beam_info_;
35
Music *prev_start_ev_;
39
Beaming_info_list *beam_info_;
40
Beaming_info_list *finished_beam_info_;
37
42
/// location within measure where beam started.
38
43
Moment beam_start_location_;
47
52
void set_melisma (bool);
49
54
Moment last_stem_added_at_;
50
virtual void stop_translation_timestep ();
51
virtual void start_translation_timestep ();
55
void stop_translation_timestep ();
56
void start_translation_timestep ();
52
57
virtual void finalize ();
54
virtual void acknowledge_grob (Grob_info);
55
virtual bool try_music (Music*);
56
virtual void process_music ();
59
virtual bool try_music (Music *);
60
void process_music ();
58
62
virtual bool valid_start_point ();
59
63
virtual bool valid_end_point ();
62
66
TRANSLATOR_DECLARATIONS (Beam_engraver);
67
70
Hmm. this isn't necessary, since grace beams and normal beams are
71
74
Beam_engraver::valid_start_point ()
143
140
set_melisma (true);
144
141
prev_start_ev_ = start_ev_;
145
beam_ = make_spanner ("Beam");
146
SCM smp = get_property ("measurePosition");
147
Moment mp = (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
142
beam_ = make_spanner ("Beam", start_ev_->self_scm ());
143
Moment mp (robust_scm2moment (get_property ("measurePosition"), Moment (0)));
149
145
beam_start_location_ = mp;
150
146
beam_start_mom_ = now_mom ();
152
148
beam_info_ = new Beaming_info_list;
154
150
/* urg, must copy to Auto_beam_engraver too */
155
announce_grob (beam_, start_ev_->self_scm ());
162
155
Beam_engraver::typeset_beam ()
223
Beam_engraver::acknowledge_grob (Grob_info info)
216
Beam_engraver::acknowledge_rest (Grob_info info)
227
if (Rest::has_interface (info.grob_))
229
info.grob_->add_offset_callback (Beam::rest_collision_callback_proc, Y_AXIS);
231
else if (Stem::has_interface (info.grob_))
233
Moment now = now_mom ();
235
if (!valid_start_point ())
238
Item *stem = dynamic_cast<Item*> (info.grob_);
239
if (Stem::get_beam (stem))
242
Music* m = info.music_cause ();
243
if (!m->is_mus_type ("rhythmic-event"))
245
String s = _ ("stem must have Rhythmic structure");
246
if (info.music_cause ())
247
info.music_cause ()->origin ()->warning (s);
255
last_stem_added_at_ = now;
256
int durlog = unsmob_duration (m->get_property ("duration"))-> duration_log ();
259
m->origin ()->warning (_ ("stem doesn't fit in beam"));
260
prev_start_ev_->origin ()->warning (_ ("beam was started here"));
264
[r4 c8] can just as well be modern notation.
268
stem->set_property ("duration-log",
269
scm_int2num (durlog));
270
Moment stem_location = now - beam_start_mom_ + beam_start_location_;
271
beam_info_->add_stem (stem_location,
273
Beam::add_stem (beam_, stem);
282
ENTER_DESCRIPTION (Beam_engraver,
283
/* descr */ "Handles Beam events by engraving Beams. If omitted, then notes will be "
284
"printed with flags instead of beams.",
286
/* accepts */ "beam-event",
287
/* acks */ "stem-interface rest-interface",
288
/* reads */ "beamMelismaBusy beatLength subdivideBeams",
220
chain_offset_callback (info.grob(),
221
Beam::rest_collision_callback_proc, Y_AXIS);
228
Beam_engraver::acknowledge_stem (Grob_info info)
233
Moment now = now_mom ();
234
if (!valid_start_point ())
237
Item *stem = dynamic_cast<Item *> (info.grob ());
238
if (Stem::get_beam (stem))
243
Music *m = info.ultimate_music_cause ();
244
if (!m->is_mus_type ("rhythmic-event"))
246
string s = _ ("stem must have Rhythmic structure");
247
if (info.music_cause ())
248
info.music_cause ()->origin ()->warning (s);
255
last_stem_added_at_ = now;
256
int durlog = unsmob_duration (m->get_property ("duration"))->duration_log ();
259
m->origin ()->warning (_ ("stem doesn't fit in beam"));
260
prev_start_ev_->origin ()->warning (_ ("beam was started here"));
264
[r4 c8] can just as well be modern notation.
268
stem->set_property ("duration-log",
269
scm_from_int (durlog));
270
Moment stem_location = now - beam_start_mom_ + beam_start_location_;
271
beam_info_->add_stem (stem_location,
273
Beam::add_stem (beam_, stem);
276
ADD_ACKNOWLEDGER (Beam_engraver, stem);
277
ADD_ACKNOWLEDGER (Beam_engraver, rest);
279
ADD_TRANSLATOR (Beam_engraver,
280
/* doc */ "Handles Beam events by engraving Beams. If omitted, then notes will be "
281
"printed with flags instead of beams.",
283
/* accept */ "beam-event",
284
/* read */ "beamMelismaBusy beatLength subdivideBeams",
292
287
class Grace_beam_engraver : public Beam_engraver
295
TRANSLATOR_DECLARATIONS (Grace_beam_engraver);
290
TRANSLATOR_DECLARATIONS (Grace_beam_engraver);
298
293
virtual bool valid_start_point ();
311
306
return n.grace_part_ != Rational (0);
316
310
Grace_beam_engraver::valid_end_point ()
318
312
return beam_ && valid_start_point ();
323
ENTER_DESCRIPTION (Grace_beam_engraver,
324
/* descr */ "Handles Beam events by engraving Beams. If omitted, then notes will "
325
"be printed with flags instead of beams. Only engraves beams when we "
326
" are at grace points in time. "
329
/* accepts */ "beam-event",
330
/* acks */ "stem-interface rest-interface",
331
/* reads */ "beamMelismaBusy beatLength allowBeamBreak subdivideBeams",
315
ADD_ACKNOWLEDGER (Grace_beam_engraver, stem);
316
ADD_ACKNOWLEDGER (Grace_beam_engraver, rest);
317
ADD_TRANSLATOR (Grace_beam_engraver,
318
/* doc */ "Handles Beam events by engraving Beams. If omitted, then notes will "
319
"be printed with flags instead of beams. Only engraves beams when we "
320
" are at grace points in time. ",
322
/* accept */ "beam-event",
323
/* read */ "beamMelismaBusy beatLength allowBeamBreak subdivideBeams",