- int staff_position = pitch_min.steps ();
- SCM c0 = get_property ("centralCPosition");
- if (gh_number_p (c0))
- staff_position += gh_scm2int (c0);
- SCM segment = scm_list_n (column_scm,
- gh_int2scm (staff_position),
- pitch_min.smobbed_copy (),
- pitch_max.smobbed_copy (),
- SCM_UNDEFINED);
- segment = scm_list_n (segment, SCM_UNDEFINED);
- columns_scm = (columns_scm != SCM_EOL) ?
- gh_append2 (columns_scm, segment) : segment;
+ if (Pitch::compare (pitch_min_, pitch_max_) <= 0)
+ {
+ Real y_bottom = 0.5 * pitch_min_.steps ();
+ SCM c0 = get_property ("centralCPosition");
+ if (gh_number_p (c0))
+ y_bottom += 0.5 * gh_scm2int (c0);
+ else
+ programming_error ("Cluster_engraver: failed evaluating c0");
+ Real y_top = y_bottom +
+ 0.5 * (pitch_max_.steps () - pitch_min_.steps ());
+ column_scm = Protected_scm (column_scm);
+ SCM segment = scm_list_n (column_scm,
+ gh_double2scm (y_bottom),
+ gh_double2scm (y_top),
+ SCM_UNDEFINED);
+ segment = scm_list_n (segment, SCM_UNDEFINED);
+ columns_scm_ = (columns_scm_ != SCM_EOL) ?
+ gh_append2 (columns_scm_, segment) : segment;
+ cluster_->set_grob_property ("segments", columns_scm_); // Urrgh!
+ }
+ else
+ {
+ /* This timestep is caused by a different voice of the
+ same staff and hence should be ignored. */
+ }