2 beam-engraver.cc -- implement Beam_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "timing-engraver.hh"
10 #include "engraver-group-engraver.hh"
11 #include "beam-engraver.hh"
12 #include "musical-request.hh"
16 #include "time-description.hh"
18 #include "score-engraver.hh"
20 Beam_engraver::Beam_engraver ()
24 finished_beam_info_p_
=0;
26 reqs_drul_
[LEFT
] = reqs_drul_
[RIGHT
] =0;
31 Beam_engraver::do_try_music (Music
*m
)
33 if (Span_req
* c
= dynamic_cast<Span_req
*>(m
))
35 if (c
->span_type_str_
!= "beam")
38 Direction d
=c
->span_dir_
;
40 if (d
== STOP
&& !beam_p_
)
42 m
->warning (_ ("No Beam to end"));
53 Beam_engraver::do_process_requests ()
58 reqs_drul_
[STOP
]->warning (_("No beam to end"));
60 finished_beam_p_
= beam_p_
;
61 finished_beam_info_p_
= beam_info_p_
;
70 Score_engraver
* e
= 0;
71 Translator
* t
= daddy_grav_l ();
72 for (; !e
&& t
; t
= t
->daddy_trans_l_
)
74 e
= dynamic_cast<Score_engraver
*> (t
);
78 programming_error ("No score engraver!");
83 if (reqs_drul_
[START
])
87 reqs_drul_
[START
]->warning (_ ("Already have a Beam"));
91 prev_start_req_
= reqs_drul_
[START
];
94 Translator
* t
= daddy_grav_l ()->get_simple_translator ("Timing_engraver");
95 Timing_engraver
*timer
= dynamic_cast<Timing_engraver
*> (t
);
96 beam_start_location_
= (t
) ? timer
->time_
.whole_in_measure_
: Moment (0);
97 beam_start_mom_
= now_mom();
98 beam_info_p_
= new Beaming_info_list
;
102 Scalar prop
= get_property ("beamslopedamping", 0);
104 beam_p_
->set_elt_property (damping_scm_sym
, gh_int2scm( prop
));
106 prop
= get_property ("beamquantisation", 0);
108 beam_p_
->quantisation_
= (Beam::Quantisation
)(int)prop
;
110 announce_element (Score_element_info (beam_p_
, reqs_drul_
[START
]));
115 Beam_engraver::typeset_beam ()
117 if (finished_beam_p_
)
119 finished_beam_info_p_
->beamify ();
121 finished_beam_p_
->set_beaming (finished_beam_info_p_
);
122 typeset_element (finished_beam_p_
);
123 delete finished_beam_info_p_
;
124 finished_beam_info_p_
=0;
125 finished_beam_p_
= 0;
127 reqs_drul_
[STOP
] = 0;
132 Beam_engraver::do_post_move_processing ()
134 reqs_drul_
[START
] =0;
138 Beam_engraver::do_pre_move_processing ()
144 Beam_engraver::do_removal_processing ()
149 prev_start_req_
->warning (_ ("Unfinished beam"));
150 finished_beam_p_
= beam_p_
;
151 finished_beam_info_p_
= beam_info_p_
;
157 Beam_engraver::acknowledge_element (Score_element_info info
)
161 Stem
* stem_l
= dynamic_cast<Stem
*> (info
.elem_l_
);
162 if (!stem_l
|| stem_l
->beam_l_
)
166 bool stem_grace
= stem_l
->get_elt_property (grace_scm_sym
) != SCM_BOOL_F
;
168 if (get_property ("weAreGraceContext",0).to_bool () != stem_grace
)
171 Rhythmic_req
*rhythmic_req
= dynamic_cast <Rhythmic_req
*> (info
.req_l_
);
174 String s
= _ ("Stem must have Rhythmic structure.");
176 info
.req_l_
->warning (s
);
183 if (rhythmic_req
->duration_
.durlog_i_
<= 2)
185 rhythmic_req
->warning (_ ("stem doesn't fit in beam"));
186 prev_start_req_
->warning (_ ("beam was started here"));
190 stem_l
->flag_i_
= rhythmic_req
->duration_
.durlog_i_
;
191 Moment stem_location
= now_mom () - beam_start_mom_
+ beam_start_location_
;
192 beam_info_p_
->add_stem (stem_location
, rhythmic_req
->duration_
.durlog_i_
- 2);
193 beam_p_
->add_stem (stem_l
);
199 ADD_THIS_TRANSLATOR(Beam_engraver
);