2 beam.cc -- implement Beam
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
13 * shorter! (now +- 1000 lines)
15 * move paper vars to scm
17 remove *-hs variables, and do all y-position stuff in staff-space.
21 #include <math.h> // tanh.
24 #include "directional-element-interface.hh"
28 #include "least-squares.hh"
30 #include "paper-def.hh"
32 #include "group-interface.hh"
33 #include "staff-symbol-referencer.hh"
34 #include "cross-staff.hh"
40 Beam::add_stem (Score_element*me, Score_element*s)
42 Pointer_group_interface gi (me, "stems");
45 s->add_dependency (me);
47 assert (!Stem::beam_l (s));
48 s->set_elt_property ("beam", me->self_scm ());
50 add_bound_item (dynamic_cast<Spanner*> (me), dynamic_cast<Item*> (s));
54 Beam::get_multiplicity (Score_element*me)
57 for (SCM s = me->get_elt_property ("stems"); gh_pair_p (s); s = gh_cdr (s))
59 Score_element * sc = unsmob_element (gh_car (s));
61 if (Stem::has_interface (sc))
62 m = m >? Stem::beam_count (sc,LEFT) >? Stem::beam_count (sc,RIGHT);
68 After pre-processing all directions should be set.
69 Several post-processing routines (stem, slur, script) need stem/beam
71 Currenly, this means that beam has set all stem's directions.
72 [Alternatively, stems could set its own directions, according to
73 their beam, during 'final-pre-processing'.]
75 MAKE_SCHEME_CALLBACK(Beam,before_line_breaking);
77 Beam::before_line_breaking (SCM smob)
79 Score_element * me = unsmob_element (smob);
82 if (visible_stem_count (me) < 2)
84 warning (_ ("beam has less than two stems"));
87 if (!Directional_element_interface (me).get ())
88 Directional_element_interface (me).set (get_default_dir (me));
91 set_stem_directions (me);
92 set_stem_shorten (me);
101 Beam::get_default_dir (Score_element*me)
103 Drul_array<int> total;
104 total[UP] = total[DOWN] = 0;
105 Drul_array<int> count;
106 count[UP] = count[DOWN] = 0;
109 Link_array<Item> stems=
110 Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
112 for (int i=0; i <stems.size (); i++)
113 do { // HUH -- waar slaat dit op?
114 Score_element *s = stems[i];
115 Direction sd = Directional_element_interface (s).get ();
116 int current = sd ? (1 + d * sd)/2
117 : Stem::get_center_distance (s, (Direction)-d);
125 } while (flip(&d) != DOWN);
128 SCM s = scm_eval (gh_list (ly_symbol2scm ("beam-dir-algorithm"),
129 ly_quote_scm (gh_cons (gh_int2scm (count[UP]),
130 gh_int2scm (count[DOWN]))),
131 ly_quote_scm (gh_cons (gh_int2scm (total[UP]),
132 gh_int2scm (total[DOWN]))),
134 if (gh_number_p (s) && gh_scm2int (s))
138 If dir is not determined: get default
140 return to_dir (me->get_elt_property ("default-neutral-direction"));
145 Set all stems with non-forced direction to beam direction.
146 Urg: non-forced should become `without/with unforced' direction,
147 once stem gets cleaned-up.
150 Beam::set_stem_directions (Score_element*me)
152 Link_array<Item> stems
153 =Pointer_group_interface__extract_elements (me, (Item*) 0, "stems");
154 Direction d = Directional_element_interface (me).get ();
156 for (int i=0; i <stems.size (); i++)
158 Score_element *s = stems[i];
159 SCM force = s->remove_elt_property ("dir-forced");
160 if (!gh_boolean_p (force) || !gh_scm2bool (force))
161 Directional_element_interface (s).set (d);
166 Beam::auto_knees (Score_element*me)
168 if (!auto_knee (me,"auto-interstaff-knee-gap", true))
169 auto_knee (me, "auto-knee-gap", false);
173 Simplistic auto-knees; only consider vertical gap between two
176 `Forced' stem directions are ignored. If you don't want auto-knees,
177 don't set, or unset autoKneeGap/autoInterstaffKneeGap.
180 Beam::auto_knee (Score_element*me, String gap_str, bool interstaff_b)
184 SCM gap = me->get_elt_property (gap_str.ch_C());
186 Direction d = Directional_element_interface (me).get ();
187 Link_array<Item> stems=
188 Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
190 if (gh_number_p (gap))
192 Spanner*sp = dynamic_cast<Spanner*> (me);
193 int auto_gap_i = gh_scm2int (gap);
194 for (int i=1; i < stems.size (); i++)
196 bool is_b = (bool)(calc_interstaff_dist (stems[i], sp)
197 - calc_interstaff_dist (stems[i-1], sp));
198 int l_y = (int)(Stem::head_positions(stems[i-1])[d])
199 + (int)calc_interstaff_dist (stems[i-1], sp);
200 int r_y = (int)(Stem::head_positions(stems[i])[d])
201 + (int)calc_interstaff_dist (stems[i], sp);
202 int gap_i = r_y - l_y;
204 if ((abs (gap_i) >= auto_gap_i) && (!interstaff_b || is_b))
206 knee_y = (r_y + l_y) / 2;
214 for (int i=0; i < stems.size (); i++)
217 int y = (int)(Stem::head_positions(s)[d])
218 + (int)calc_interstaff_dist (s, dynamic_cast<Spanner*> (me));
220 Directional_element_interface (s).set (y < knee_y ? UP : DOWN);
221 s->set_elt_property ("dir-forced", SCM_BOOL_T);
228 Set stem's shorten property if unset.
230 take some y-position (chord/beam/nearest?) into account
231 scmify forced-fraction
234 Beam::set_stem_shorten (Score_element*m)
236 Spanner*me = dynamic_cast<Spanner*> (m);
237 if (!visible_stem_count (me))
240 Real forced_fraction = forced_stem_count (me) / visible_stem_count (me);
241 if (forced_fraction < 0.5)
244 int multiplicity = get_multiplicity (me);
247 SCM shorten = scm_eval (ly_symbol2scm ("beamed-stem-shorten"));
249 if (shorten == SCM_EOL)
252 int sz = scm_ilength (shorten);
254 Real staff_space = Staff_symbol_referencer::staff_space (me);
255 SCM shorten_elt = scm_list_ref (shorten, gh_int2scm (multiplicity <? (sz - 1)));
256 Real shorten_f = gh_scm2double (shorten_elt) * staff_space;
258 /* cute, but who invented me -- how to customise ? */
259 if (forced_fraction < 1)
262 Link_array<Item> stems=
263 Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
265 for (int i=0; i < stems.size (); i++)
268 if (Stem::invisible_b (s))
270 if (gh_number_p (s->get_elt_property ("shorten")))
271 s->set_elt_property ("shorten", gh_double2scm (shorten_f));
276 Set elt properties height and y-position if not set.
277 Adjust stem lengths to reach beam.
279 MAKE_SCHEME_CALLBACK(Beam,after_line_breaking);
281 Beam::after_line_breaking (SCM smob)
283 Score_element * me = unsmob_element (smob);
285 /* first, calculate y, dy */
287 calc_default_position_and_height (me, &y, &dy);
288 if (visible_stem_count (me))
290 if (suspect_slope_b (me, y, dy))
293 Real damped_dy = calc_slope_damping_f (me, dy);
294 Real quantised_dy = quantise_dy_f (me, damped_dy);
296 y += (dy - quantised_dy) / 2;
300 until here, we used only stem_info, which acts as if dir=up
302 y *= Directional_element_interface (me).get ();
303 dy *= Directional_element_interface (me).get ();
306 Real half_space = Staff_symbol_referencer::staff_space (me) / 2;
308 /* weird: why do we do calc_position_and_height () ? regardless of
312 /* check for user-override of dy */
313 SCM s = me->remove_elt_property ("height-hs");
316 dy = gh_scm2double (s) * half_space;
318 me->set_elt_property ("height", gh_double2scm (dy));
320 /* check for user-override of y */
321 s = me->remove_elt_property ("y-position-hs");
324 y = gh_scm2double (s) * half_space;
328 /* we can modify y, so we should quantise y */
329 Real y_shift = check_stem_length_f (me, y, dy);
331 y = quantise_y_f (me,y, dy, 0);
332 set_stem_length (me, y, dy);
333 y_shift = check_stem_length_f (me, y, dy);
335 if (y_shift > half_space / 4)
340 for significantly lengthened or shortened stems,
341 request quanting the other way.
344 if (abs (y_shift) > half_space / 2)
345 quant_dir = sign (y_shift) * Directional_element_interface (me).get ();
346 y = quantise_y_f (me, y, dy, quant_dir);
349 // UGH. Y is not in staff position unit?
350 // Ik dacht datwe daar juist van weg wilden?
351 set_stem_length (me, y, dy);
352 me->set_elt_property ("y-position", gh_double2scm (y));
354 return SCM_UNSPECIFIED;
358 See Documentation/tex/fonts.doc
361 Beam::calc_default_position_and_height (Score_element*me,Real* y, Real* dy)
365 if (visible_stem_count (me) <= 1)
368 Real first_ideal = Stem::calc_stem_info (first_visible_stem (me)).idealy_f_;
369 if (first_ideal == Stem::calc_stem_info (last_visible_stem (me)).idealy_f_)
376 Array<Offset> ideals;
378 // ugh -> use commonx
379 Real x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS);
380 Link_array<Item> stems=
381 Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
383 for (int i=0; i < stems.size (); i++)
386 if (Stem::invisible_b (s))
388 ideals.push (Offset (s->relative_coordinate (0, X_AXIS) - x0,
389 Stem::calc_stem_info (s).idealy_f_));
392 minimise_least_squares (&dydx, y, ideals); // duh, takes references
394 Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0;
399 Beam::suspect_slope_b (Score_element*me, Real y, Real dy)
401 /* first, calculate y, dy */
403 steep slope running against lengthened stem is suspect
405 Real first_ideal = Stem::calc_stem_info (first_visible_stem (me)).idealy_f_;
406 Real last_ideal = Stem::calc_stem_info (last_visible_stem (me)).idealy_f_;
407 Real lengthened = me->paper_l ()->get_var ("beam_lengthened");
408 Real steep = me->paper_l ()->get_var ("beam_steep_slope");
410 // ugh -> use commonx
411 Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - first_visible_stem (me)->relative_coordinate (0, X_AXIS);
412 Real dydx = dy && dx ? dy/dx : 0;
414 if (((y - first_ideal > lengthened) && (dydx > steep))
415 || ((y + dy - last_ideal > lengthened) && (dydx < -steep)))
423 This neat trick is by Werner Lemberg,
424 damped = tanh (slope)
425 corresponds with some tables in [Wanske]
428 Beam::calc_slope_damping_f (Score_element*me,Real dy)
430 SCM damp = me->get_elt_property ("damping");
431 int damping = gh_scm2int (damp);
435 // ugh -> use commonx
436 Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS)
437 - first_visible_stem (me)->relative_coordinate (0, X_AXIS);
438 Real dydx = dy && dx ? dy/dx : 0;
439 dydx = 0.6 * tanh (dydx) / damping;
446 Beam::calc_stem_y_f (Score_element*me,Item* s, Real y, Real dy)
448 Real thick = gh_scm2double (me->get_elt_property ("beam-thickness"));
449 thick *= me->paper_l ()->get_var ("staffspace");
451 int beam_multiplicity = get_multiplicity (me);
452 int stem_multiplicity = (Stem::flag_i (s) - 2) >? 0;
454 Real interbeam_f = me->paper_l ()->interbeam_f (beam_multiplicity);
455 // ugh -> use commonx
456 Real x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS);
457 Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0;
458 Real stem_y = (dy && dx ? (s->relative_coordinate (0, X_AXIS) - x0) / dx * dy : 0) + y;
461 Direction dir = Directional_element_interface(me).get ();
462 Direction sdir = Directional_element_interface (s).get ();
468 * (thick / 2 + (beam_multiplicity - 1) * interbeam_f);
472 // huh, why not for first visible?
473 if (Staff_symbol_referencer::staff_symbol_l (s)
474 != Staff_symbol_referencer::staff_symbol_l (last_visible_stem (me)))
475 stem_y += Directional_element_interface (me).get ()
476 * (beam_multiplicity - stem_multiplicity) * interbeam_f;
483 Beam::check_stem_length_f (Score_element*me,Real y, Real dy)
487 Direction dir = Directional_element_interface (me).get ();
489 Link_array<Item> stems=
490 Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
492 for (int i=0; i < stems.size(); i++)
495 if (Stem::invisible_b (s))
498 Real stem_y = calc_stem_y_f (me, s, y, dy);
501 Stem_info info = Stem::calc_stem_info (s);
503 // if (0 > info.maxy_f_ - stem_y)
504 shorten = shorten <? info.maxy_f_ - stem_y;
505 // if (0 < info.miny_f_ - stem_y)
506 lengthen = lengthen >? info.miny_f_ - stem_y;
509 if (lengthen && shorten)
510 warning (_ ("weird beam vertical offset"));
512 /* when all stems are too short, normal stems win */
513 return dir * ((shorten) ? shorten : lengthen);
517 Hmm. At this time, beam position and slope are determined. Maybe,
518 stem directions and length should set to relative to the chord's
519 position of the beam. */
521 Beam::set_stem_length (Score_element*me,Real y, Real dy)
523 Real half_space = Staff_symbol_referencer::staff_space (me)/2;
524 Link_array<Item> stems=
525 Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
528 for (int i=0; i < stems.size (); i++)
531 if (Stem::invisible_b (s))
534 Real stem_y = calc_stem_y_f (me, s, y, dy);
536 /* caution: stem measures in staff-positions */
537 Stem::set_stemend (s,(stem_y + calc_interstaff_dist (s, dynamic_cast<Spanner*> (me))) / half_space);
542 [Ross] (simplification of)
543 Set dy complying with:
545 - thick / 2 + staffline_f / 2
546 - thick + staffline_f
550 Beam::quantise_dy_f (Score_element*me,Real dy)
553 for (SCM s = scm_eval (ly_symbol2scm ("beam-height-quants")); s !=SCM_EOL; s = gh_cdr (s))
554 a.push (gh_scm2double (gh_car (s)));
559 Real staff_space = Staff_symbol_referencer::staff_space (me);
561 Interval iv = quantise_iv (a, abs (dy)/staff_space) * staff_space;
562 Real q = (abs (dy) - iv[SMALLER] <= iv[BIGGER] - abs (dy))
566 return q * sign (dy);
570 Prevent interference from stafflines and beams.
571 See Documentation/tex/fonts.doc
573 We only need to quantise the (left) y-position of the beam,
574 since dy is quantised too.
575 if extend_b then stems must *not* get shorter
578 Beam::quantise_y_f (Score_element*me,Real y, Real dy, int quant_dir)
580 int multiplicity = get_multiplicity (me);
582 Real staff_space = Staff_symbol_referencer::staff_space (me);
583 SCM quants = scm_eval (gh_list (ly_symbol2scm ("beam-vertical-position-quants"),
584 gh_int2scm (multiplicity),
585 gh_double2scm (dy/staff_space),
590 for (; quants != SCM_EOL; quants = gh_cdr (quants))
591 a.push (gh_scm2double (gh_car (quants)));
596 Real up_y = Directional_element_interface (me).get () * y;
597 Interval iv = quantise_iv (a, up_y/staff_space) * staff_space;
599 Real q = up_y - iv[SMALLER] <= iv[BIGGER] - up_y
600 ? iv[SMALLER] : iv[BIGGER];
602 q = iv[(Direction)quant_dir];
604 return q * Directional_element_interface (me).get ();
608 Beam::set_beaming (Score_element*me,Beaming_info_list *beaming)
610 Link_array<Score_element> stems=
611 Pointer_group_interface__extract_elements (me, (Score_element*)0, "stems");
614 for (int i=0; i < stems.size(); i++)
618 if (Stem::beam_count (stems[i], d) == 0)
619 Stem::set_beaming ( stems[i], beaming->infos_.elem (i).beams_i_drul_[d],d);
621 while (flip (&d) != LEFT);
628 beams to go with one stem.
634 Beam::stem_beams (Score_element*me,Item *here, Item *next, Item *prev)
636 // ugh -> use commonx
637 if ((next && !(next->relative_coordinate (0, X_AXIS) > here->relative_coordinate (0, X_AXIS))) ||
638 (prev && !(prev->relative_coordinate (0, X_AXIS) < here->relative_coordinate (0, X_AXIS))))
639 programming_error ("Beams are not left-to-right");
641 Real staffline_f = me->paper_l ()->get_var ("stafflinethickness");
642 int multiplicity = get_multiplicity (me);
645 Real interbeam_f = me->paper_l ()->interbeam_f (multiplicity);
646 Real thick = gh_scm2double (me->get_elt_property ("beam-thickness"));
647 thick *= me->paper_l ()->get_var ("staffspace");
649 Real bdy = interbeam_f;
650 Real stemdx = staffline_f;
652 // ugh -> use commonx
653 Real dx = visible_stem_count (me) ?
654 last_visible_stem (me)->relative_coordinate (0, X_AXIS) - first_visible_stem (me)->relative_coordinate (0, X_AXIS)
656 Real dy = gh_scm2double (me->get_elt_property ("height"));
657 Real dydx = dy && dx ? dy/dx : 0;
664 if (!Stem::first_head (here))
666 else if (Stem::type_i (here)== 1)
667 nw_f = me->paper_l ()->get_var ("wholewidth");
668 else if (Stem::type_i (here) == 2)
669 nw_f = me->paper_l ()->get_var ("notewidth") * 0.8;
671 nw_f = me->paper_l ()->get_var ("quartwidth");
674 Direction dir = Directional_element_interface (me).get ();
676 /* half beams extending to the left. */
679 int lhalfs= lhalfs = Stem::beam_count (here,LEFT) - Stem::beam_count (prev,RIGHT);
680 int lwholebeams= Stem::beam_count (here,LEFT) <? Stem::beam_count (prev,RIGHT) ;
682 Half beam should be one note-width,
683 but let's make sure two half-beams never touch
685 Real w = here->relative_coordinate (0, X_AXIS) - prev->relative_coordinate (0, X_AXIS);
688 if (lhalfs) // generates warnings if not
689 a = me->lookup_l ()->beam (dydx, w, thick);
690 a.translate (Offset (-w, -w * dydx));
691 for (int j = 0; j < lhalfs; j++)
694 b.translate_axis (-dir * bdy * (lwholebeams+j), Y_AXIS);
695 leftbeams.add_molecule (b);
701 int rhalfs = Stem::beam_count (here,RIGHT) - Stem::beam_count (next,LEFT);
702 int rwholebeams= Stem::beam_count (here,RIGHT) <? Stem::beam_count (next,LEFT) ;
704 Real w = next->relative_coordinate (0, X_AXIS) - here->relative_coordinate (0, X_AXIS);
705 Molecule a = me->lookup_l ()->beam (dydx, w + stemdx, thick);
706 a.translate_axis( - stemdx/2, X_AXIS);
710 SCM gap = me->get_elt_property ("beam-gap");
711 if (gh_number_p (gap))
713 int gap_i = gh_scm2int ( (gap));
714 int nogap = rwholebeams - gap_i;
716 for (; j < nogap; j++)
719 b.translate_axis (-dir * bdy * j, Y_AXIS);
720 rightbeams.add_molecule (b);
722 // TODO: notehead widths differ for different types
725 a = me->lookup_l ()->beam (dydx, w + stemdx, thick);
728 for (; j < rwholebeams; j++)
731 b.translate (Offset (Stem::invisible_b (here) ? 0 : gap_f, -dir * bdy * j));
732 rightbeams.add_molecule (b);
737 a = me->lookup_l ()->beam (dydx, w, thick);
739 for (; j < rwholebeams + rhalfs; j++)
742 b.translate_axis (- dir * bdy * j, Y_AXIS);
743 rightbeams.add_molecule (b);
747 leftbeams.add_molecule (rightbeams);
750 Does beam quanting think of the asymetry of beams?
751 Refpoint is on bottom of symbol. (FIXTHAT) --hwn.
756 MAKE_SCHEME_CALLBACK(Beam,brew_molecule);
758 Beam::brew_molecule (SCM smob)
760 Score_element * me =unsmob_element (smob);
763 if (!gh_pair_p (me->get_elt_property ("stems")))
766 Link_array<Item>stems =
767 Pointer_group_interface__extract_elements (me, (Item*) 0, "stems");
768 if (visible_stem_count (me))
770 // ugh -> use commonx
771 x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS);
772 dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0;
776 x0 = stems[0]->relative_coordinate (0, X_AXIS);
777 dx = stems.top()->relative_coordinate (0, X_AXIS) - x0;
781 Real dy = gh_scm2double (me->get_elt_property ("height"));
782 Real dydx = dy && dx ? dy/dx : 0;
783 Real y = gh_scm2double (me->get_elt_property ("y-position"));
786 for (int j=0; j <stems.size (); j++)
789 Item * prev = (j > 0)? stems[j-1] : 0;
790 Item * next = (j < stems.size()-1) ? stems[j+1] :0;
792 Molecule sb = stem_beams (me, i, next, prev);
793 Real x = i->relative_coordinate (0, X_AXIS)-x0;
794 sb.translate (Offset (x, x * dydx + y));
795 mol.add_molecule (sb);
797 mol.translate_axis (x0
798 - dynamic_cast<Spanner*> (me)->get_bound (LEFT)->relative_coordinate (0, X_AXIS), X_AXIS);
800 return mol.create_scheme ();
804 Beam::forced_stem_count (Score_element*me)
806 Link_array<Item>stems =
807 Pointer_group_interface__extract_elements ( me, (Item*) 0, "stems");
809 for (int i=0; i < stems.size (); i++)
813 if (Stem::invisible_b (s))
816 if (((int)Stem::chord_start_f (s))
817 && (Stem::get_direction (s ) != Stem::get_default_dir (s )))
827 use filter and standard list functions.
830 Beam::visible_stem_count (Score_element*me)
832 Link_array<Item>stems =
833 Pointer_group_interface__extract_elements (me, (Item*) 0, "stems");
835 for (int i = stems.size (); i--;)
837 if (!Stem::invisible_b (stems[i]))
844 Beam::first_visible_stem(Score_element*me)
846 Link_array<Item>stems =
847 Pointer_group_interface__extract_elements ( me, (Item*) 0, "stems");
849 for (int i = 0; i < stems.size (); i++)
851 if (!Stem::invisible_b (stems[i]))
858 Beam::last_visible_stem(Score_element*me)
860 Link_array<Item>stems =
861 Pointer_group_interface__extract_elements ( me, (Item*) 0, "stems");
862 for (int i = stems.size (); i--;)
864 if (!Stem::invisible_b (stems[i]))
873 handle rest under beam (do_post: beams are calculated now)
874 what about combination of collisions and rest under beam.
878 rest -> stem -> beam -> interpolate_y_position ()
881 Beam::rest_collision_callback (Score_element *rest, Axis a )
883 assert (a == Y_AXIS);
885 Score_element * st = unsmob_element (rest->get_elt_property ("stem"));
886 Score_element * stem = st;
889 Score_element * beam = unsmob_element (stem->get_elt_property ("beam"));
890 if (!beam || !Beam::has_interface (beam) || !Beam::visible_stem_count (beam))
893 // make callback for rest from this.
898 // todo: make sure this calced already.
899 SCM s = beam->get_elt_property ("height");
901 beam_dy = gh_scm2double (s);
903 s = beam->get_elt_property ("y-position");
905 beam_y = gh_scm2double (s);
907 // ugh -> use commonx
908 Real x0 = first_visible_stem(beam)->relative_coordinate (0, X_AXIS);
909 Real dx = last_visible_stem(beam)->relative_coordinate (0, X_AXIS) - x0;
910 Real dydx = beam_dy && dx ? beam_dy/dx : 0;
912 Direction d = Stem::get_direction (stem);
913 Real beamy = (stem->relative_coordinate (0, X_AXIS) - x0) * dydx + beam_y;
915 Real staff_space = Staff_symbol_referencer::staff_space (rest);
916 Real rest_dim = rest->extent (Y_AXIS)[d]*2.0 / staff_space ;
919 = gh_scm2double (rest->get_elt_property ("minimum-beam-collision-distance"));
921 minimum_dist + -d * (beamy - rest_dim) >? 0;
923 int stafflines = Staff_symbol_referencer::line_count (rest);
925 // move discretely by half spaces.
926 int discrete_dist = int (ceil (dist));
928 // move by whole spaces inside the staff.
929 if (discrete_dist < stafflines+1)
930 discrete_dist = int (ceil (discrete_dist / 2.0)* 2.0);
932 return (-d * discrete_dist);
937 Beam::has_interface (Score_element*me)
939 return me->has_interface (ly_symbol2scm ("beam-interface"));
943 Beam::set_interface (Score_element*me)
945 Pointer_group_interface g (me, "stems");
949 why the init? No way to tell difference between default and user
951 me->set_elt_property ("height", gh_int2scm (0)); // ugh.
952 me->set_elt_property ("y-position" ,gh_int2scm (0));
953 me->set_interface (ly_symbol2scm("beam-interface"));