- if (Note_head*h=dynamic_cast<Note_head*> (o))
- head_l_arr_.substitute (h, dynamic_cast<Note_head*>(n));
- if (Rest *r=dynamic_cast<Rest*> (o))
- rest_l_arr_.substitute (r, dynamic_cast<Rest*>(n));
- if (Beam* b = dynamic_cast<Beam*> (o))
+ assert (beam_l ());
+
+ Direction beam_dir = directional_element (beam_l ()).get ();
+ if (!beam_dir)
+ {
+ programming_error ("Beam dir not set.");
+ beam_dir = UP;
+ }
+
+ Staff_symbol_referencer_interface st (this);
+ Real staff_space = st.staff_space ();
+ Real half_space = staff_space / 2;
+ Real interbeam_f = paper_l ()->interbeam_f (beam_l ()->get_multiplicity ());
+ Real thick = gh_scm2double (beam_l ()->get_elt_property ("beam-thickness"));
+ int multiplicity = beam_l ()->get_multiplicity ();
+
+ Stem_info info;
+ info.idealy_f_ = chord_start_f ();
+
+ // for simplicity, we calculate as if dir == UP
+ info.idealy_f_ *= beam_dir;
+ SCM grace_prop = get_elt_property ("grace");
+
+ bool grace_b = to_boolean (grace_prop);
+
+ Array<Real> a;
+ SCM s;
+ String type_str = grace_b ? "grace-" : "";
+
+ s = scm_eval (ly_symbol2scm ((type_str + "beamed-stem-minimum-length").ch_C()));
+ a.clear ();
+ for (SCM q = s; q != SCM_EOL; q = gh_cdr (q))
+ a.push (gh_scm2double (gh_car (q)));
+
+
+ Real minimum_length = a[multiplicity <? (a.size () - 1)] * staff_space;
+ s = scm_eval (ly_symbol2scm ((type_str + "beamed-stem-length").ch_C()));
+
+ a.clear();
+ for (SCM q = s; q != SCM_EOL; q = gh_cdr (q))
+ a.push (gh_scm2double (gh_car (q)));
+
+ Real stem_length = a[multiplicity <? (a.size () - 1)] * staff_space;
+
+ if (!beam_dir || (beam_dir == directional_element (this).get ()))
+ /* normal beamed stem */