2 measure-grouping-engraver.cc -- implement Measure_grouping_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 2002--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "side-position-interface.hh"
11 #include "global-context.hh"
12 #include "engraver.hh"
14 #include "beam-settings.hh"
16 #include "translator.icc"
18 class Measure_grouping_engraver
: public Engraver
21 TRANSLATOR_DECLARATIONS (Measure_grouping_engraver
);
25 Rational stop_grouping_mom_
;
27 void process_music ();
28 virtual void finalize ();
29 DECLARE_ACKNOWLEDGER (note_column
);
33 Measure_grouping_engraver::finalize ()
37 grouping_
->set_bound (RIGHT
, unsmob_grob (get_property ("currentCommandColumn")));
38 grouping_
->suicide ();
44 Measure_grouping_engraver::acknowledge_note_column (Grob_info gi
)
47 Side_position_interface::add_support (grouping_
, gi
.grob ());
51 Measure_grouping_engraver::process_music ()
53 Moment now
= now_mom ();
54 if (grouping_
&& now
.main_part_
>= stop_grouping_mom_
&& !now
.grace_part_
)
56 grouping_
->set_bound (RIGHT
,
57 unsmob_grob (get_property ("currentMusicalColumn")));
65 SCM settings
= get_property ("beamSettings");
66 SCM grouping
= SCM_EOL
;
67 if (scm_is_pair (settings
))
69 SCM time_signature_fraction
= get_property ("timeSignatureFraction");
70 grouping
= ly_beam_grouping (settings
,
71 time_signature_fraction
,
72 ly_symbol2scm ("end"),
75 if (scm_is_pair (grouping
))
77 Moment
*measpos
= unsmob_moment (get_property ("measurePosition"));
78 Rational mp
= measpos
->main_part_
;
80 Moment
*beatlen_mom
= unsmob_moment (get_property ("beatLength"));
81 Rational beat_length
= beatlen_mom
->main_part_
;
84 for (SCM s
= grouping
; scm_is_pair (s
);
85 where
+= Rational ((int) scm_to_int (scm_car (s
))) * beat_length
,
88 int grouplen
= scm_to_int (scm_car (s
));
93 programming_error ("last grouping not finished yet");
98 grouping_
= make_spanner ("MeasureGrouping", SCM_EOL
);
99 grouping_
->set_bound (LEFT
, unsmob_grob (get_property ("currentMusicalColumn")));
101 stop_grouping_mom_
= now
.main_part_
+ Rational (grouplen
- 1) * beat_length
;
102 get_global_context ()->add_moment_to_process (Moment (stop_grouping_mom_
));
105 grouping_
->set_property ("style", ly_symbol2scm ("triangle"));
107 grouping_
->set_property ("style", ly_symbol2scm ("bracket"));
116 Measure_grouping_engraver::Measure_grouping_engraver ()
121 ADD_ACKNOWLEDGER (Measure_grouping_engraver
, note_column
);
122 ADD_TRANSLATOR (Measure_grouping_engraver
,
124 "Create @code{MeasureGrouping} to indicate beat subdivision.",
131 "currentMusicalColumn "