From f9eafe65e3d281e6cd07a25d8b6b19cc1eada1de Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Wed, 8 Dec 1999 23:12:24 +0100 Subject: [PATCH] patch::: 1.3.10.jcn1 pl 10.jcn1 - steminfo to properties - dropped internote dim for stem-beams --- CHANGES | 4 + VERSION | 2 +- lily/beam.cc | 166 ++++++++++++----------------- lily/chord-tremolo-engraver.cc | 2 +- lily/file-results.cc | 1 - lily/include/beam.hh | 17 ++- lily/include/glob.hh | 9 -- lily/include/new-beaming.hh | 2 - lily/include/new-repeated-music.hh | 2 - lily/include/parseconstruct.hh | 2 - lily/include/score-element.hh | 3 + lily/include/stem-info.hh | 33 ------ lily/include/stem.hh | 1 + lily/include/symbols.hh | 1 - lily/score-element.cc | 13 ++- lily/stem-info.cc | 138 ------------------------ lily/stem-staff-side.cc | 1 - lily/stem-tremolo.cc | 16 +-- lily/stem.cc | 108 +++++++++++++++++++ ly/params.ly | 4 +- 20 files changed, 215 insertions(+), 310 deletions(-) diff --git a/CHANGES b/CHANGES index 6742e3945c..9e4c61e8a0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +pl 10.jcn1 + - steminfo to properties + - dropped internote dim for stem-beams + pl 9.hwn1 - abstracting Staff_symbol_referencer to an interface. - quantised_position for staccato dots. diff --git a/VERSION b/VERSION index 978773045b..48ade71e1d 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 PATCH_LEVEL=10 -MY_PATCH_LEVEL= +MY_PATCH_LEVEL=jcn1 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/lily/beam.cc b/lily/beam.cc index 0335ff7256..c8c1dd0229 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -44,7 +44,7 @@ Beam::Beam () slope_f_ = 0; left_y_ = 0; - multiple_i_ = 0; + multiplicity_i_ = 0; } /* @@ -63,6 +63,12 @@ Beam::stem_count ()const return gi.count (); } +Stem* +Beam::stem_top ()const +{ + return Group_interface__extract_elements ((Beam*) this, (Stem*) 0, "stems")[stem_count () - 1]; +} + void Beam::add_stem (Stem*s) @@ -81,24 +87,11 @@ Beam::add_stem (Stem*s) set_bounds (RIGHT,s); } -Stem_info -Beam::get_stem_info (Stem *s) -{ - Stem_info i; - for (int i=0; i < sinfo_.size (); i++) - { - if (sinfo_[i].stem_l_ == s) - return sinfo_[i]; - } - assert (false); - return i; -} - Molecule* Beam::do_brew_molecule_p () const { Molecule *mol_p = new Molecule; - if (!sinfo_.size ()) + if (!stem_count ()) return mol_p; Real x0 = stem (0)->hpos_f (); @@ -110,8 +103,7 @@ Beam::do_brew_molecule_p () const Molecule sb = stem_beams (i, next, prev); Real x = i->hpos_f ()-x0; - sb.translate (Offset (x, (x * slope_f_ + left_y_) * - i->staff_line_leading_f ()/2 )); + sb.translate (Offset (x, x * slope_f_ + left_y_)); mol_p->add_molecule (sb); } mol_p->translate_axis (x0 @@ -123,11 +115,8 @@ Beam::do_brew_molecule_p () const Offset Beam::center () const { - Stem_info si = sinfo_[0]; - - Real w= (si.stem_l_->note_delta_f () + extent (X_AXIS).length ())/2.0; - return Offset (w, ( w* slope_f_) * - si.stem_l_->staff_line_leading_f ()/2); + Real w = (stem (0)->note_delta_f () + extent (X_AXIS).length ())/2.0; + return Offset (w, w * slope_f_); } /* @@ -139,17 +128,16 @@ Beam::auto_knee (SCM gap, bool interstaff_b) { bool knee = false; int knee_y = 0; - Real internote_f = stem (0)->staff_line_leading_f ()/2; if (gap != SCM_UNDEFINED) { int auto_gap_i = gh_scm2int (gap); for (int i=1; i < stem_count (); i++) { - bool is_b = (bool)(sinfo_[i].interstaff_f_ - sinfo_[i-1].interstaff_f_); - int l_y = (int)(stem (i-1)->chord_start_f () / internote_f) - + (int)sinfo_[i-1].interstaff_f_; - int r_y = (int)(stem (i)->chord_start_f () / internote_f) - + (int)sinfo_[i].interstaff_f_; + bool is_b = (bool)(stem (i)->get_real ("interstaff-f") - stem (i-1)->get_real ("interstaff-f")); + int l_y = (int)(stem (i-1)->chord_start_f ()) + + (int)stem (i-1)->get_real ("interstaff-f"); + int r_y = (int)(stem (i)->chord_start_f ()) + + (int)stem (i)->get_real ("interstaff-f"); int gap_i = r_y - l_y; /* @@ -168,8 +156,8 @@ Beam::auto_knee (SCM gap, bool interstaff_b) { for (int i=0; i < stem_count (); i++) { - int y = (int)(stem (i)->chord_start_f () / internote_f) - + (int)sinfo_[i].interstaff_f_; + int y = (int)(stem (i)->chord_start_f ()) + + (int)stem (i)->get_real ("interstaff-f"); stem (i)->set_direction ( y < knee_y ? UP : DOWN); stem (i)->set_elt_property ("dir-forced", SCM_BOOL_T); } @@ -218,14 +206,14 @@ Beam::do_post_processing () set_elt_property ("transparent", SCM_BOOL_T); return; } - set_steminfo (); + beamify_stems (); if (auto_knees ()) { /* if auto-knee did its work, most probably stem directions have changed, so we must recalculate all. */ - set_direction ( get_default_dir ()); + set_direction (get_default_dir ()); set_direction (get_direction ()); /* auto-knees used to only work for slope = 0 @@ -233,8 +221,7 @@ Beam::do_post_processing () set_elt_property ("damping", gh_int2scm(1000)); */ - sinfo_.clear (); - set_steminfo (); + beamify_stems (); } calculate_slope (); set_stemlens (); @@ -338,12 +325,14 @@ Beam::set_direction (Direction d) void Beam::solve_slope () { - assert (sinfo_.size () > 1); + assert (stem_count () > 1); Least_squares l; - for (int i=0; i < sinfo_.size (); i++) + Real x0 = stem (0)->hpos_f (); + for (int i=0; i < stem_count (); i++) { - l.input.push (Offset (sinfo_[i].x_, sinfo_[i].idealy_f_)); + l.input.push (Offset (stem (i)->hpos_f () - x0, + stem (i)->get_real ("idealy-f"))); } l.minimise (slope_f_, left_y_); } @@ -355,52 +344,55 @@ Beam::solve_slope () Real Beam::check_stemlengths_f (bool set_b) { - Real interbeam_f = paper_l ()->interbeam_f (multiple_i_); + Real interbeam_f = paper_l ()->interbeam_f (multiplicity_i_); Real beam_f = gh_scm2double (get_elt_property ("beam-thickness")); Real staffline_f = paper_l ()-> get_var ("stafflinethickness"); Real epsilon_f = staffline_f / 8; Real dy_f = 0.0; - for (int i=0; i < sinfo_.size (); i++) + Real x0 = stem (0)->hpos_f (); + Real internote_f = paper_l ()->get_var ("interline"); + for (int i=0; i < stem_count (); i++) { - Real y = sinfo_[i].x_ * slope_f_ + left_y_; + Real y = (stem (i)->hpos_f () - x0) * slope_f_ + left_y_; // correct for knee - if (get_direction () != sinfo_[i].get_direction ()) + if (get_direction () != stem (i)->get_direction ()) { - Real internote_f = sinfo_[i].stem_l_->staff_line_leading_f ()/2; y -= get_direction () * (beam_f / 2 - + (sinfo_[i].mult_i_ - 1) * interbeam_f) / internote_f; - if (!i && sinfo_[i].stem_l_->staff_symbol_l () != - sinfo_.top ().stem_l_->staff_symbol_l ()) - y += get_direction () * (multiple_i_ - (sinfo_[i].stem_l_->flag_i_ - 2) >? 0) - * interbeam_f / internote_f; + + (multiplicity_i_ - 1) * interbeam_f); + if (!i + && stem (i)->staff_symbol_l () != stem_top ()->staff_symbol_l ()) + y += get_direction () * (multiplicity_i_ - (stem (i)->flag_i_ - 2) >? 0) + * interbeam_f; } + /* caution: stem measures in staff-positions */ if (set_b) - sinfo_[i].stem_l_->set_stemend (y - sinfo_[i].interstaff_f_); + stem (i)->set_stemend ((y - stem (i)->get_real ("interstaff-f")) + / internote_f); y *= get_direction (); - if (y > sinfo_[i].maxy_f_) - dy_f = dy_f stem (i)->get_real ("maxy-f")) + dy_f = dy_f get_real ("maxy-f") - y; + if (y < stem (i)->get_real ("miny-f")) { // when all too short, normal stems win.. if (dy_f < -epsilon_f) warning (_ ("weird beam vertical offset")); - dy_f = dy_f >? sinfo_[i].miny_f_ - y; + dy_f = dy_f >? stem (i)->get_real ("miny-f") - y; } } return dy_f; } void -Beam::set_steminfo () +Beam::beamify_stems () { if(!stem_count ()) return; - assert (multiple_i_); + assert (multiplicity_i_); int total_count_i = 0; int forced_count_i = 0; @@ -416,13 +408,13 @@ Beam::set_steminfo () total_count_i++; } + Real internote_f = paper_l ()->get_var ("interline"); bool grace_b = get_elt_property ("grace") == SCM_BOOL_T; String type_str = grace_b ? "grace_" : ""; int stem_max = (int)rint(paper_l ()->get_var ("stem_max")); Real shorten_f = paper_l ()->get_var (type_str + "forced_stem_shorten" - + to_str (multiple_i_ beamify (); + if (s->get_direction () == get_direction ()) { if (forced_count_i == total_count_i) - info.idealy_f_ -= shorten_f; + s->set_real ("idealy-f", s->get_real ("idealy-f") - shorten_f); else if (forced_count_i > total_count_i / 2) - info.idealy_f_ -= shorten_f / 2; + s->set_real ("idealy-f", s->get_real ("idealy-f") - shorten_f/2); } - sinfo_.push (info); } } void Beam::calculate_slope () { - if (!sinfo_.size ()) + if (!stem_count ()) slope_f_ = left_y_ = 0; - else if (sinfo_[0].idealy_f_ == sinfo_.top ().idealy_f_) + else if (stem (0)->get_real ("idealy-f") == stem_top ()->get_real ("idealy-f")) { slope_f_ = 0; - left_y_ = sinfo_[0].idealy_f_; + left_y_ = stem (0)->get_real ("idealy-f"); left_y_ *= get_direction (); } else @@ -472,14 +460,11 @@ Beam::calculate_slope () */ Real dx_f = stem (stem_count () -1)->hpos_f () - stem (0)->hpos_f (); - // urg, these y internote-y-dimensions - Real internote_f = stem (0)->staff_line_leading_f ()/2; - - Real lengthened = paper_l ()->get_var ("beam_lengthened") / internote_f; - Real steep = paper_l ()->get_var ("beam_steep_slope") / internote_f; - if (((left_y_ - sinfo_[0].idealy_f_ > lengthened) + Real lengthened = paper_l ()->get_var ("beam_lengthened"); + Real steep = paper_l ()->get_var ("beam_steep_slope"); + if (((left_y_ - stem (0)->get_real ("idealy-f") > lengthened) && (slope_f_ > steep)) - || ((left_y_ + slope_f_ * dx_f - sinfo_.top ().idealy_f_ > lengthened) + || ((left_y_ + slope_f_ * dx_f - stem_top ()->get_real ("idealy-f") > lengthened) && (slope_f_ < -steep))) { slope_f_ = 0; @@ -526,14 +511,12 @@ Beam::quantise_dy () return; Real interline_f = stem (0)->staff_line_leading_f (); - Real internote_f = interline_f / 2; Real staffline_f = paper_l ()->get_var ("stafflinethickness"); Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));; Real dx_f = stem (stem_count () -1 )->hpos_f () - stem (0)->hpos_f (); - // dim(y) = internote; so slope = (y/internote)/x - Real dy_f = dx_f * abs (slope_f_ * internote_f); + Real dy_f = dx_f * abs (slope_f_); Real quanty_f = 0.0; @@ -542,14 +525,12 @@ Beam::quantise_dy () allowed_fraction[1] = (beam_f / 2 + staffline_f / 2); allowed_fraction[2] = (beam_f + staffline_f); - Interval iv = quantise_iv (allowed_fraction, interline_f, dy_f); quanty_f = (dy_f - iv[SMALLER] <= iv[BIGGER] - dy_f) ? iv[SMALLER] : iv[BIGGER]; - - slope_f_ = (quanty_f / dx_f) / internote_f * sign (slope_f_); + slope_f_ = (quanty_f / dx_f) * sign (slope_f_); } /* @@ -579,7 +560,6 @@ Beam::quantise_left_y (bool extend_b) */ Real space = stem (0)->staff_line_leading_f (); - Real internote_f = space /2; Real staffline_f = paper_l ()->get_var ("stafflinethickness"); Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));; @@ -603,27 +583,26 @@ Beam::quantise_left_y (bool extend_b) */ // isn't this asymmetric ? --hwn - // dim(left_y_) = internote - Real dy_f = get_direction () * left_y_ * internote_f; + Real dy_f = get_direction () * left_y_; Real beamdx_f = stem (stem_count () -1)->hpos_f () - stem (0)->hpos_f (); - Real beamdy_f = beamdx_f * slope_f_ * internote_f; + Real beamdy_f = beamdx_f * slope_f_; Array allowed_position; if (q == ly_symbol2scm ("normal")) { - if ((multiple_i_ <= 2) || (abs (beamdy_f) >= staffline_f / 2)) + if ((multiplicity_i_ <= 2) || (abs (beamdy_f) >= staffline_f / 2)) allowed_position.push (straddle); - if ((multiple_i_ <= 1) || (abs (beamdy_f) >= staffline_f / 2)) + if ((multiplicity_i_ <= 1) || (abs (beamdy_f) >= staffline_f / 2)) allowed_position.push (sit); allowed_position.push (hang); } else if (q == ly_symbol2scm ("traditional")) { // TODO: check and fix TRADITIONAL - if ((multiple_i_ <= 2) || (abs (beamdy_f) >= staffline_f / 2)) + if ((multiplicity_i_ <= 2) || (abs (beamdy_f) >= staffline_f / 2)) allowed_position.push (straddle); - if ((multiple_i_ <= 1) && (beamdy_f <= staffline_f / 2)) + if ((multiplicity_i_ <= 1) && (beamdy_f <= staffline_f / 2)) allowed_position.push (sit); if (beamdy_f >= -staffline_f / 2) allowed_position.push (hang); @@ -636,8 +615,7 @@ Beam::quantise_left_y (bool extend_b) if (extend_b) quanty_f = iv[BIGGER]; - // dim(left_y_) = internote - left_y_ = get_direction () * quanty_f / internote_f; + left_y_ = get_direction () * quanty_f; } void @@ -685,7 +663,7 @@ Beam::do_add_processing () { Direction d = LEFT; do { - multiple_i_ = multiple_i_ >? stem (i)->beams_i_drul_[d]; + multiplicity_i_ = multiplicity_i_ >? stem (i)->beams_i_drul_[d]; } while ((flip (&d)) != LEFT); } @@ -714,14 +692,12 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const programming_error ("Beams are not left-to-right"); Real staffline_f = paper_l ()->get_var ("stafflinethickness"); - Real interbeam_f = paper_l ()->interbeam_f (multiple_i_); - - Real internote_f = here->staff_line_leading_f ()/2; + Real interbeam_f = paper_l ()->interbeam_f (multiplicity_i_); Real beam_f = gh_scm2double (get_elt_property ("beam-thickness"));; Real dy = interbeam_f; Real stemdx = staffline_f; - Real sl = slope_f_* internote_f; + Real sl = slope_f_; Molecule leftbeams; Molecule rightbeams; diff --git a/lily/chord-tremolo-engraver.cc b/lily/chord-tremolo-engraver.cc index 567c31ec6a..427e0d76e6 100644 --- a/lily/chord-tremolo-engraver.cc +++ b/lily/chord-tremolo-engraver.cc @@ -142,7 +142,7 @@ Chord_tremolo_engraver::acknowledge_element (Score_element_info i) s->beams_i_drul_[LEFT] = s->flag_i_; s->beams_i_drul_[RIGHT] = s->flag_i_; - abeam_p_->multiple_i_ = s->flag_i_; + abeam_p_->multiplicity_i_ = s->flag_i_; /* abbrev gaps on all but half note */ diff --git a/lily/file-results.cc b/lily/file-results.cc index 8b13789179..e69de29bb2 100644 --- a/lily/file-results.cc +++ b/lily/file-results.cc @@ -1 +0,0 @@ - diff --git a/lily/include/beam.hh b/lily/include/beam.hh index cfcc305e65..67c443eee6 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -9,7 +9,6 @@ #include "lily-proto.hh" #include "directional-spanner.hh" -#include "stem-info.hh" /** a beam connects multiple stems. @@ -31,6 +30,7 @@ public: int stem_count ()const; Stem * stem (int )const; + Stem* Beam::stem_top ()const; /** the slope of the beam in (staffpositions) per (X-dimension, in PT). @@ -41,15 +41,14 @@ public: /// position of leftmost end of beam Real left_y_; + /** + highest number of beams present, for opening-up of beam-spacing + and calculation of stem lengths + */ + int multiplicity_i_; - /// maximum number of beams (for opening-up of beam-spacing) - int multiple_i_; - - Array sinfo_; - - Beam(); + Beam (); void add_stem (Stem*); - Stem_info get_stem_info (Stem*); void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current); void set_beaming (Beaming_info_list *); @@ -60,7 +59,7 @@ protected: Offset center () const; Direction get_default_dir () const; void set_direction (Direction); - void set_steminfo (); + void beamify_stems (); bool auto_knee (SCM gap, bool interstaff_b); bool auto_knees (); diff --git a/lily/include/glob.hh b/lily/include/glob.hh index 3bb2fe7601..e69de29bb2 100644 --- a/lily/include/glob.hh +++ b/lily/include/glob.hh @@ -1,9 +0,0 @@ -#ifndef GLOB_HH -#define GLOB_HH -#include -#include -#include "real.hh" - -#include "lily-proto.hh" -#include "const.hh" -#endif diff --git a/lily/include/new-beaming.hh b/lily/include/new-beaming.hh index 65296f8106..e69de29bb2 100644 --- a/lily/include/new-beaming.hh +++ b/lily/include/new-beaming.hh @@ -1,2 +0,0 @@ - -#error diff --git a/lily/include/new-repeated-music.hh b/lily/include/new-repeated-music.hh index 65296f8106..e69de29bb2 100644 --- a/lily/include/new-repeated-music.hh +++ b/lily/include/new-repeated-music.hh @@ -1,2 +0,0 @@ - -#error diff --git a/lily/include/parseconstruct.hh b/lily/include/parseconstruct.hh index 65296f8106..e69de29bb2 100644 --- a/lily/include/parseconstruct.hh +++ b/lily/include/parseconstruct.hh @@ -1,2 +0,0 @@ - -#error diff --git a/lily/include/score-element.hh b/lily/include/score-element.hh index f5a26a030f..c799408ee8 100644 --- a/lily/include/score-element.hh +++ b/lily/include/score-element.hh @@ -74,6 +74,9 @@ public: void set_elt_property (String, SCM val); SCM remove_elt_property (String nm); + void Score_element::set_real (String, Real); + Real Score_element::get_real (String s) const; + /* related classes. */ diff --git a/lily/include/stem-info.hh b/lily/include/stem-info.hh index 248f71b82d..e69de29bb2 100644 --- a/lily/include/stem-info.hh +++ b/lily/include/stem-info.hh @@ -1,33 +0,0 @@ -/* - stem-info.hh -- declare Stem_info - - source file of the GNU LilyPond music typesetter - - (c) 1997--1999 Jan Nieuwenhuizen -*/ - - -#ifndef STEM_INFO_HH -#define STEM_INFO_HH - -#include "real.hh" - -struct Stem_info { - Real x_; - Direction dir_; - void set_direction (Direction d ) { dir_ = d; } - Direction get_direction () const { return dir_; } - - int beam_dir_; - Real idealy_f_; - Real miny_f_; - Real maxy_f_; - int mult_i_; - Real interstaff_f_; - Stem* stem_l_; - - Stem_info (); - Stem_info (Stem *, int); -}; - -#endif // STEM_INFO_HH diff --git a/lily/include/stem.hh b/lily/include/stem.hh index 3f1b583565..6f6fd75782 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -69,6 +69,7 @@ public: /// ensure that this Stem also encompasses the Notehead #n# void add_head (Rhythmic_head*n); + void beamify (); Real hpos_f () const; Real chord_start_f () const; diff --git a/lily/include/symbols.hh b/lily/include/symbols.hh index 8b13789179..e69de29bb2 100644 --- a/lily/include/symbols.hh +++ b/lily/include/symbols.hh @@ -1 +0,0 @@ - diff --git a/lily/score-element.cc b/lily/score-element.cc index 45fbc03ed6..5e958affaa 100644 --- a/lily/score-element.cc +++ b/lily/score-element.cc @@ -27,7 +27,6 @@ #include "staff-side.hh" #include "item.hh" - Score_element::Score_element() { output_p_ =0; @@ -109,6 +108,18 @@ Score_element::dependency_size () const return dependency_arr_.size (); } +Real +Score_element::get_real (String s) const +{ + return gh_scm2double (get_elt_property (s)); +} + +void +Score_element::set_real (String s, Real r) +{ + set_elt_property (s, gh_double2scm (r)); +} + // should also have one that takes SCM arg. SCM Score_element::get_elt_property (String nm) const diff --git a/lily/stem-info.cc b/lily/stem-info.cc index ee0faf9721..e69de29bb2 100644 --- a/lily/stem-info.cc +++ b/lily/stem-info.cc @@ -1,138 +0,0 @@ -/* - stem-info.cc -- implement Stem_info - - source file of the GNU LilyPond music typesetter - - (c) 1997--1999 Jan Nieuwenhuizen - -*/ - -#include "proto.hh" -#include "misc.hh" -#include "cross-staff.hh" -#include "debug.hh" -#include "stem.hh" -#include "paper-def.hh" -#include "lookup.hh" -#include "stem-info.hh" -#include "beam.hh" - - -Stem_info::Stem_info () -{ -} - - -/* - FIXME: y dims should not be in internote. - - - GURG UGRGINRG INA UG R - - JUNKME -> this should set elt properties of STEM. -*/ -Stem_info::Stem_info (Stem*s, int mult) -{ - mult_i_ =mult; - stem_l_ = s; - Beam* beam_l = stem_l_->beam_l (); - - x_ = stem_l_->hpos_f (); - set_direction (stem_l_->get_direction ()); - SCM bd = stem_l_->remove_elt_property ("beam-dir"); - - if (gh_number_p (bd)) - { - beam_dir_ = gh_scm2int (bd); - } - else - { - programming_error ("Beam direction not set."); - beam_dir_ = UP; // GURAUGRNAGURAGU! urg ! - } - - Paper_def* paper_l = stem_l_->paper_l (); - Real internote_f = stem_l_->staff_line_leading_f ()/2; - Real interbeam_f = paper_l->interbeam_f (mult_i_); - Real beam_f = gh_scm2double (beam_l->get_elt_property ("beam-thickness")); - - - // strangely enough, dim(chord_start_f) == pt (and not internote!) - idealy_f_ = stem_l_->chord_start_f () / internote_f; - - // calculate using dim(y) == pt - idealy_f_ *= internote_f; - - // for simplicity, we calculate as if dir == UP - idealy_f_ *= beam_dir_; - - bool grace_b = stem_l_->get_elt_property ("grace") != SCM_UNDEFINED; - bool no_extend_b = stem_l_->get_elt_property ("no-stem-extend") - != SCM_UNDEFINED; - - int stem_max = (int)rint(paper_l->get_var ("stem_max")); - String type_str = grace_b ? "grace_" : ""; - Real min_stem_f = paper_l->get_var (type_str + "minimum_stem_length" - + to_str (mult_i_ get_var (type_str + "stem_length" - + to_str (mult_i_ ? 0; - //lowest beam of (UP) beam must never be lower than second staffline - miny_f_ = miny_f_ >? (- 2 * internote_f - beam_f - + (mult_i_ > 0) * beam_f + interbeam_f * (mult_i_ - 1)); - } - } - else - /* knee */ - { - idealy_f_ -= beam_f; - maxy_f_ = idealy_f_; - miny_f_ = -INT_MAX; - - idealy_f_ -= stem_f; - maxy_f_ -= min_stem_f; - } - - // set dim(y) == internote - idealy_f_ /= internote_f; - miny_f_ /= internote_f; - maxy_f_ /= internote_f; - - idealy_f_ = maxy_f_ ? idealy_f_; - - interstaff_f_ = calc_interstaff_dist (stem_l_, beam_l) / internote_f; - idealy_f_ += interstaff_f_* beam_dir_; - miny_f_ += interstaff_f_ * beam_dir_; - maxy_f_ += interstaff_f_ * beam_dir_; -} - - diff --git a/lily/stem-staff-side.cc b/lily/stem-staff-side.cc index 8b13789179..e69de29bb2 100644 --- a/lily/stem-staff-side.cc +++ b/lily/stem-staff-side.cc @@ -1 +0,0 @@ - diff --git a/lily/stem-tremolo.cc b/lily/stem-tremolo.cc index d55cd55272..fc6df56fa8 100644 --- a/lily/stem-tremolo.cc +++ b/lily/stem-tremolo.cc @@ -52,28 +52,25 @@ Stem_tremolo::do_brew_molecule_p () const int mult =0; if (Beam * b = st->beam_l ()) { - Stem_info i = b->get_stem_info (st); - mult = i.mult_i_; + mult = b->multiplicity_i_; } Real interbeam_f = paper_l ()->interbeam_f (mult); Real w = gh_scm2double (get_elt_property ("beam-width")); Real space = st->staff_line_leading_f (); - Real internote_f = space/2; - + Real internote_f = space / 2; Real beam_f = gh_scm2double (get_elt_property ("beam-thickness")); int beams_i = 0; - Real slope_f = internote_f / 4 / internote_f; // HUH? + Real slope_f = 0.25; if (st && st->beam_l ()) { slope_f = st->beam_l ()->slope_f_; // ugh, rather calc from Stem_tremolo_req beams_i = st->beams_i_drul_[RIGHT] >? st->beams_i_drul_[LEFT]; } - Real sl = slope_f * internote_f; - Molecule a (lookup_l ()->beam (sl, w, beam_f)); + Molecule a (lookup_l ()->beam (slope_f, w, beam_f)); a.translate (Offset (-w/2, w / 2 * slope_f)); Molecule *beams= new Molecule; @@ -107,12 +104,7 @@ Stem_tremolo::do_brew_molecule_p () const ? -st->get_direction () * st->note_delta_f ()/2 : 0.0; - /* - UGH. Internote fudging. - */ - dy /= internote_f; dy += st->stem_end_f (); - dy *= internote_f; beams->translate (Offset(st->hpos_f () - hpos_f ()+ whole_note_correction, dy)); } diff --git a/lily/stem.cc b/lily/stem.cc index 1edd92bc53..74b92dd89d 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -4,6 +4,7 @@ source file of the GNU LilyPond music typesetter (c) 1996, 1997--1999 Han-Wen Nienhuys + Jan Nieuwenhuizen TODO: This is way too hairy */ @@ -19,6 +20,7 @@ #include "beam.hh" #include "rest.hh" #include "group-interface.hh" +#include "cross-staff.hh" Stem::Stem () { @@ -398,3 +400,109 @@ Stem::beam_l ()const SCM b= get_elt_property ("beam"); return dynamic_cast (unsmob_element (b)); } + + +/* + stupid name: we're calculating and setting (caching??) + some stem length parameters for beamed stem +*/ +void +Stem::beamify () +{ + assert (beam_l ()); + + SCM bd = remove_elt_property ("beam-dir"); + Real internote_f = staff_line_leading_f ()/2; + + Direction beam_dir; + Real idealy_f; + Real interstaff_f; + Real maxy_f; + Real miny_f; + + if (gh_number_p (bd)) + { + beam_dir = (Direction)gh_scm2int (bd); + } + else + { + programming_error ("Beam direction not set."); + beam_dir = UP; // GURAUGRNAGURAGU! urg ! + } + + Real interbeam_f = paper_l ()->interbeam_f (beam_l ()->multiplicity_i_); + Real beam_f = gh_scm2double (beam_l ()->get_elt_property ("beam-thickness")); + + idealy_f = chord_start_f (); + + // for simplicity, we calculate as if dir == UP + idealy_f *= beam_dir; + + bool grace_b = get_elt_property ("grace") != SCM_UNDEFINED; + bool no_extend_b = get_elt_property ("no-stem-extend") != SCM_UNDEFINED; + + int stem_max = (int)rint(paper_l ()->get_var ("stem_max")); + String type_str = grace_b ? "grace_" : ""; + Real min_stem_f = paper_l ()->get_var (type_str + "minimum_stem_length" + + to_str (beam_l ()->multiplicity_i_ get_var (type_str + "stem_length" + + to_str (beam_l ()->multiplicity_i_ multiplicity_i_) + { + idealy_f += beam_f; + idealy_f += (beam_l ()->multiplicity_i_ - 1) * interbeam_f; + } + miny_f = idealy_f; + maxy_f = INT_MAX; + + idealy_f += stem_f; + miny_f += min_stem_f; + + /* + lowest beam of (UP) beam must never be lower than second staffline + + Hmm, reference (Wanske?) + + Although this (additional) rule is probably correct, + I expect that highest beam (UP) should also never be lower + than middle staffline, just as normal stems. + + */ + if (!grace_b && !no_extend_b) + { + //highest beam of (UP) beam must never be lower than middle staffline + miny_f = miny_f >? 0; + //lowest beam of (UP) beam must never be lower than second staffline + miny_f = miny_f >? (- 2 * internote_f - beam_f + + (beam_l ()->multiplicity_i_ > 0) * beam_f + interbeam_f * (beam_l ()->multiplicity_i_ - 1)); + } + } + else + /* knee */ + { + idealy_f -= beam_f; + maxy_f = idealy_f; + miny_f = -INT_MAX; + + idealy_f -= stem_f; + maxy_f -= min_stem_f; + } + + idealy_f = maxy_f ? idealy_f; + + interstaff_f = calc_interstaff_dist (this, beam_l ()); + idealy_f += interstaff_f * beam_dir; + miny_f += interstaff_f * beam_dir; + maxy_f += interstaff_f * beam_dir; + + set_elt_property ("interstaff-f", gh_double2scm (interstaff_f)); + set_elt_property ("idealy-f", gh_double2scm (idealy_f)); + set_elt_property ("miny-f", gh_double2scm (miny_f)); + set_real ("maxy-f", gh_double2scm (maxy_f)); +} + diff --git a/ly/params.ly b/ly/params.ly index 4e60c76a01..bbeba93841 100644 --- a/ly/params.ly +++ b/ly/params.ly @@ -29,7 +29,7 @@ stem_max = 3.0; %{ Specify length of stems for notes in the staff that don't have beams. - Measured in staff positions. + Measured in staff positions. %} stem_length0 = 7.; stem_length1 = 5.; @@ -63,7 +63,7 @@ grace_stem_length3 = \stem_length3 * \grace_factor; % only used for beams minimum_stem_length0 = 0.0 ; % not used -minimum_stem_length1 = 3. ; +minimum_stem_length1 = 3.; minimum_stem_length2 = 2.5; minimum_stem_length3 = 2.0; -- 2.39.2