From: fred Date: Wed, 27 Mar 2002 01:20:55 +0000 (+0000) Subject: lilypond-1.5.7 X-Git-Tag: release/1.5.59~578 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=a967c0ff146b32978ae02fa91b363bf0b885c441;p=lilypond.git lilypond-1.5.7 --- diff --git a/input/regression/grace-sync.ly b/input/regression/grace-sync.ly index 69efcd5df6..8e44e82570 100644 --- a/input/regression/grace-sync.ly +++ b/input/regression/grace-sync.ly @@ -6,7 +6,7 @@ \grace c8 c4 c4 } \context Staff = SB { c2 \clef bass - \grace { [dis8 ( d8] } + \grace { [dis8 ( d8] \key es\major } ) c4 c4 } \context Staff = SC { c2 c4 c4 \bar "|." } diff --git a/input/regression/spacing-folded-clef.ly b/input/regression/spacing-folded-clef.ly new file mode 100644 index 0000000000..287d634d0c --- /dev/null +++ b/input/regression/spacing-folded-clef.ly @@ -0,0 +1,12 @@ +\header { +texidoc = "A clef can be folded below notes in a different staff, if +this doesn't disrupt the flow of the notes." +} + +\score { \notes \relative c'' < +\context Staff = SA { c4 [c16 c c c] c4 c4 } + \context Staff = SB { \clef bass c,2 \clef treble c'2 } + > + + \paper { linewidth = -1. } + } diff --git a/input/regression/spacing-grace.ly b/input/regression/spacing-grace.ly new file mode 100644 index 0000000000..3b4b32bfa7 --- /dev/null +++ b/input/regression/spacing-grace.ly @@ -0,0 +1,9 @@ +\header { + texidoc = "Grace note spacing. Should be tuned? " +} + +\score { + \notes \context Voice \relative c'' { \grace { [c16 d] } c4 } + \paper { linewidth =-1. } + +} diff --git a/input/regression/spacing-very-tight.ly b/input/regression/spacing-very-tight.ly index b6fdb49970..79808154d6 100644 --- a/input/regression/spacing-very-tight.ly +++ b/input/regression/spacing-very-tight.ly @@ -1,11 +1,15 @@ \version "1.3.148" \header { +texidoc = " When tightly spaced, hinterfleisch -> 0. Stems may touch the bar lines, opposite stems may touch eachother. We need a mininum of about a note-width/interline space in these situations, so that in tightly spaced music all vertical lines are about equally spaced. -} + + " + + } \score { \notes \relative c''{ r1 e4 f, e' f, diff --git a/lily/include/column-x-positions.hh b/lily/include/column-x-positions.hh index e8688d3bcd..830fa867ab 100644 --- a/lily/include/column-x-positions.hh +++ b/lily/include/column-x-positions.hh @@ -14,6 +14,8 @@ struct Column_x_positions { Link_array cols_; + Link_array loose_cols_; + Array config_; Real force_f_; bool satisfies_constraints_b_; diff --git a/lily/include/new-spacing-spanner.hh b/lily/include/new-spacing-spanner.hh index 0af0bc5737..ac1ac80696 100644 --- a/lily/include/new-spacing-spanner.hh +++ b/lily/include/new-spacing-spanner.hh @@ -17,7 +17,7 @@ class New_spacing_spanner { public: static void set_interface (Grob*); - static void do_measure (Grob*,Link_array const &) ; + static void do_measure (Grob*,Link_array *) ; static void stretch_to_regularity (Grob*, Array *, Link_array const &); static void breakable_column_spacing (Item* l, Item *r); DECLARE_SCHEME_CALLBACK (set_springs, (SCM )); diff --git a/lily/include/simple-spacer.hh b/lily/include/simple-spacer.hh index 2f13a107d2..8115e25587 100644 --- a/lily/include/simple-spacer.hh +++ b/lily/include/simple-spacer.hh @@ -63,7 +63,8 @@ struct Spring_description struct Simple_spacer { Array springs_; - + Link_array spaced_cols_; + Link_array loose_cols_; Real force_f_; Real indent_f_; Real line_len_f_; diff --git a/lily/line-of-score.cc b/lily/line-of-score.cc index 9c70f62adb..a6cff9391f 100644 --- a/lily/line-of-score.cc +++ b/lily/line-of-score.cc @@ -123,6 +123,66 @@ Line_of_score::output_lines () } } +/* + Find the loose columns in POSNS, and drape them around the columns + specified in BETWEEN-COLS. */ +void +set_loose_columns (Line_of_score* which, Column_x_positions const *posns) +{ + for (int i = 0; iloose_cols_.size (); i++) + { + int divide_over = 1; + Item *loose = dynamic_cast (posns->loose_cols_[i]); + Paper_column* col = dynamic_cast (loose); + + if (col->line_l_) + continue; + + + Item * left = 0; + Item * right = 0; + while (1) + { + + SCM between = loose->get_grob_property ("between-cols"); + if (!gh_pair_p (between)) + break; + + if (!left) + { + left = dynamic_cast (unsmob_grob (gh_car (between))); + left = left->column_l (); + } + divide_over ++; + loose = dynamic_cast (unsmob_grob (gh_cdr (between))); + loose = loose->column_l (); + } + + right = loose; + + Real rx = right->relative_coordinate (right->parent_l (X_AXIS), X_AXIS); + Real lx = left->relative_coordinate (left->parent_l (X_AXIS), X_AXIS); + + int j = 1; + loose = col; + while (1) + { + SCM between = loose->get_grob_property ("between-cols"); + if (!gh_pair_p (between)) + break; + + Paper_column *thiscol = dynamic_cast (loose); + + thiscol->line_l_ = which; + thiscol->translate_axis (lx + j*(rx - lx)/divide_over, X_AXIS); + + j ++; + loose = dynamic_cast (unsmob_grob (gh_cdr (between))); + } + + } +} + // const? void Line_of_score::break_into_pieces (Array const &breaking) @@ -142,7 +202,7 @@ Line_of_score::break_into_pieces (Array const &breaking) c[j]->translate_axis (breaking[i].config_[j],X_AXIS); dynamic_cast (c[j])->line_l_ = line_l; } - + set_loose_columns (line_l, &breaking[i]); broken_into_l_arr_.push (line_l); } } diff --git a/lily/new-spacing-spanner.cc b/lily/new-spacing-spanner.cc index b67c373fcb..4ed9c7afde 100644 --- a/lily/new-spacing-spanner.cc +++ b/lily/new-spacing-spanner.cc @@ -39,7 +39,7 @@ New_spacing_spanner::set_interface (Grob*me) */ void -New_spacing_spanner::do_measure (Grob*me, Link_array const & cols) +New_spacing_spanner::do_measure (Grob*me, Link_array *cols) { Moment shortest; Moment mean_shortest; @@ -50,12 +50,18 @@ New_spacing_spanner::do_measure (Grob*me, Link_array const & cols) Moment base_shortest_duration = *unsmob_moment (me->get_grob_property ("maximum-duration-for-spacing")); shortest.set_infinite (1); + for (int i = cols->size(); i--;) + { + if (gh_pair_p (cols->elem(i)->get_grob_property ("between-cols"))) + cols->del (i); + } + int n = 0; - for (int i =0 ; i < cols.size (); i++) + for (int i =0 ; i < cols->size (); i++) { - if (Paper_column::musical_b (cols[i])) + if (Paper_column::musical_b (cols->elem (i))) { - Moment *when = unsmob_moment (cols[i]->get_grob_property ("when")); + Moment *when = unsmob_moment (cols->elem (i)->get_grob_property ("when")); /* ignore grace notes for shortest notes. @@ -63,7 +69,7 @@ New_spacing_spanner::do_measure (Grob*me, Link_array const & cols) if (when && when->grace_part_) continue; - SCM st = cols[i]->get_grob_property ("shortest-starter-duration"); + SCM st = cols->elem (i)->get_grob_property ("shortest-starter-duration"); Moment this_shortest = *unsmob_moment (st); shortest = shortest const & cols) Array springs; Item * first_col = 0; - for (int i= 0; i < cols.size () - 1; i++) + for (int i= 0; i < cols->size () - 1; i++) { - Item * l = dynamic_cast (cols[i]); + Item * l = dynamic_cast (cols->elem (i)); if (!first_col && Paper_column::musical_b (l)) first_col = l; - SCM between = cols[i]->get_grob_property ("between-cols"); - if (gh_pair_p (between) - && i > 0 - && i < cols.size ()-1 - && (gh_cdr (between) != cols[i+1]->self_scm () - || gh_car (between) != cols[i-1]->self_scm ()) - ) - continue ; - - int j = i+1; - for (; j < cols.size () - 1; j++) - { - if (Paper_column::musical_b (cols[j])) - break; - - SCM between = cols[j]->get_grob_property ("between-cols"); - if (!gh_pair_p (between)) - continue; - - if (gh_car (between) == cols[i]->self_scm () ) - break ; - } - - Item * r = dynamic_cast (cols[j]); + Item * r = dynamic_cast (cols->elem (i+1)); Paper_column * lc = dynamic_cast (l); Paper_column *rc = dynamic_cast (r); @@ -370,7 +353,7 @@ New_spacing_spanner::get_duration_space (Grob*me, Moment d, Moment shortest) Real New_spacing_spanner::note_spacing (Grob*me, Grob *lc, Grob *rc, - Moment shortest) + Moment shortest) { Moment shortest_playing_len = 0; SCM s = lc->get_grob_property ("shortest-playing-duration"); @@ -391,15 +374,32 @@ New_spacing_spanner::note_spacing (Grob*me, Grob *lc, Grob *rc, shortest = 1; } Moment delta_t = Paper_column::when_mom (rc) - Paper_column::when_mom (lc); - Real dist = get_duration_space (me, shortest_playing_len, shortest); + Real dist = 0.0; + if (delta_t.main_part_) + { + dist = get_duration_space (me, shortest_playing_len, shortest); + dist *= (double) (delta_t.main_part_ / shortest_playing_len.main_part_); + } + else if (delta_t.grace_part_) + { + dist = get_duration_space (me, shortest, shortest); + Real grace_fact = 1.0; + SCM gf = me->get_grob_property ("grace-space-factor"); + if (gh_number_p (gf)) + grace_fact = gh_scm2double (gf); + + dist *= grace_fact; + } + +#if 0 /* - ugh: 0.1 is an arbitrary distance. + TODO: figure out how to space grace notes. */ - dist *= (double) (delta_t.main_part_ / shortest_playing_len.main_part_) - + 0.1 * (double) (delta_t.grace_part_ / shortest_playing_len.main_part_); + dist *= + + grace_fact * (double) (delta_t.grace_part_ / shortest_playing_len.main_part_); Moment *lm = unsmob_moment (lc->get_grob_property ("when")); @@ -412,7 +412,7 @@ New_spacing_spanner::note_spacing (Grob*me, Grob *lc, Grob *rc, else if (!rm->grace_part_ && lm->grace_part_) dist *= 0.7; } - +#endif return dist; } @@ -483,7 +483,7 @@ New_spacing_spanner::set_springs (SCM smob) if (Item::breakable_b (sc)) { Link_array measure (all.slice (j, i+1)); - do_measure (me, measure); + do_measure (me, &measure); j = i; } } diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc index d102e35bdb..9a1c85d51b 100644 --- a/lily/separating-group-spanner.cc +++ b/lily/separating-group-spanner.cc @@ -96,6 +96,7 @@ Separating_group_spanner::set_spacing_rods (SCM smob) find_rods (rb, gh_cdr (s)); } + find_musical_sequences (me); #if 0 /* TODO; restore this. @@ -126,6 +127,84 @@ Separating_group_spanner::add_spacing_unit (Grob* me ,Item*i) } +void +Separating_group_spanner::find_musical_sequences (Grob *me) +{ + Item *last = 0; + Item *llast = 0; + for (SCM s = me->get_grob_property ("elements"); + gh_pair_p (s); s = gh_cdr (s)) + { + Item *it = dynamic_cast (unsmob_grob (gh_car (s))); + if (last) + { + Item *lcol = last->column_l (); + Item *col = it->column_l (); + + int lrank = Paper_column::rank_i (lcol); + int rank = Paper_column ::rank_i (col); + + bool mus = Paper_column::musical_b (col); + bool lmus = Paper_column::musical_b (lcol); + + if ((lrank - rank == 2) && lmus && mus) + { + SCM seq = col->get_grob_property ("spacing-sequence"); + col->set_grob_property ("spacing-sequence", + gh_cons (gh_cons (it->self_scm (), last->self_scm ()), seq)); + } + + if (llast && !Paper_column::breakable_b (last)) + { + Item *llcol = llast->column_l (); + int llrank = Paper_column::rank_i (llcol); + bool llmus= Paper_column::musical_b (llcol); + if (llrank - lrank == 1 + && lrank - rank == 1 + && llmus && !lmus && mus) + { + SCM seq = col->get_grob_property ("spacing-sequence"); + col->set_grob_property ("spacing-sequence", + gh_cons (gh_cons (it->self_scm (), last->self_scm ()), seq)); + } + else if (!lmus) + { + SCM between = lcol->get_grob_property ("between-cols"); + + if (!gh_pair_p (between)) + { + between = gh_cons (it->self_scm (), llast->self_scm ()); + lcol ->set_grob_property ("between-cols", between); + } + + Item * left + = dynamic_cast (unsmob_grob (gh_car (between))); + if(Paper_column::rank_i (left->column_l ()) < rank) + gh_set_car_x (between, col->self_scm()); + + Item * right + = dynamic_cast (unsmob_grob (gh_cdr (between))); + if (Paper_column::rank_i (right->column_l ()) > llrank ) + gh_set_cdr_x (between, llcol->self_scm ()); + } + } + } + + llast = last; + last = it; + } +} + +#if 0 +void +Separating_group_spanner::set_loose_rods () +{ + // loose columns should also generate minimum distances. + // TODO +} +#endif + + void Separating_group_spanner::set_interface (Grob*) { diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc index 0de0777d9d..6c3811b8e2 100644 --- a/lily/separating-line-group-engraver.cc +++ b/lily/separating-line-group-engraver.cc @@ -20,12 +20,6 @@ protected: Item * break_malt_p_; Item * musical_malt_p_; - /* - malt_p_ : we used to have a Single_malt_grouping_item - - */ - Item * last_step_musical_malt_p_; - Spanner * sep_span_p_; virtual void acknowledge_grob (Grob_info); @@ -39,7 +33,6 @@ public: Separating_line_group_engraver::Separating_line_group_engraver () { - last_step_musical_malt_p_ = 0; sep_span_p_ = 0; break_malt_p_ = 0; musical_malt_p_ =0; @@ -102,26 +95,12 @@ Separating_line_group_engraver::stop_translation_timestep () } if (musical_malt_p_) - { + { Separating_group_spanner::add_spacing_unit (sep_span_p_, musical_malt_p_); - - if (last_step_musical_malt_p_) - { - Paper_column *col = - last_step_musical_malt_p_->column_l(); - SCM newtup = gh_cons (last_step_musical_malt_p_->self_scm (), - musical_malt_p_->self_scm ()); - col->set_grob_property ("spacing-sequence", - gh_cons (newtup, - col->get_grob_property ("spacing-sequence"))); - } - typeset_grob (musical_malt_p_); - } - last_step_musical_malt_p_ = musical_malt_p_; - musical_malt_p_ =0; - + } + musical_malt_p_ =0; } diff --git a/lily/simple-spacer.cc b/lily/simple-spacer.cc index 0340596ad3..6671a6edb6 100644 --- a/lily/simple-spacer.cc +++ b/lily/simple-spacer.cc @@ -167,11 +167,19 @@ Simple_spacer::my_solve_natural_len () void Simple_spacer::add_columns (Link_array cols) { + for (int i = cols.size (); i--;) + if (gh_pair_p (cols[i]->get_grob_property ("between-cols"))) + { + loose_cols_.push (cols[i]); + cols.del (i); + } + + spaced_cols_ = cols; for (int i=0; i < cols.size () - 1; i++) { - SCM spring_params = SCM_UNDEFINED; + SCM spring_params = SCM_EOL; for (SCM s = cols[i]->get_grob_property ("ideal-distances"); - spring_params == SCM_UNDEFINED && gh_pair_p (s); + !gh_pair_p (spring_params) && gh_pair_p (s); s = gh_cdr (s)) { Grob *other = unsmob_grob (gh_caar (s)); @@ -182,7 +190,7 @@ Simple_spacer::add_columns (Link_array cols) } Spring_description desc; - if (spring_params != SCM_UNDEFINED) + if (gh_pair_p (spring_params)) { desc.ideal_f_ = gh_scm2double (gh_car (spring_params)); desc.hooke_f_ = gh_scm2double (gh_cdr (spring_params)); @@ -199,6 +207,9 @@ Simple_spacer::add_columns (Link_array cols) if (!desc.sane_b ()) { programming_error ("Insane spring found. Setting to unit spring."); + + cout << "columns " << Paper_column::rank_i (cols[i]) + << " " << Paper_column::rank_i (cols[i+1]) << endl; desc.hooke_f_ = 1.0; desc.ideal_f_ = 1.0; } @@ -240,7 +251,9 @@ Simple_spacer::solve (Column_x_positions *positions) const { positions->config_.push (positions->config_.top () + springs_[i].length (force_f_)); } - + positions->cols_ = spaced_cols_; + positions->loose_cols_ = loose_cols_; + positions->satisfies_constraints_b_ = (line_len_f_ < 0) || active_b (); } diff --git a/scm/grob-description.scm b/scm/grob-description.scm index 0a76e6263c..c24f369723 100644 --- a/scm/grob-description.scm +++ b/scm/grob-description.scm @@ -502,7 +502,7 @@ (SpacingSpanner . ( (spacing-procedure . ,Spacing_spanner::set_springs) (stem-spacing-correction . 0.5) - + (grace-space-factor . 0.8) ;; TODO: change naming -- unintuitive (arithmetic-basicspace . 2.0) diff --git a/scripts/update-lily.py b/scripts/update-lily.py index b1fdd3420f..1d16dbdbf3 100644 --- a/scripts/update-lily.py +++ b/scripts/update-lily.py @@ -5,7 +5,8 @@ # source file of the GNU LilyPond music typesetter # # download and rebuild latest lilypond or from specified url -# +# + ''' TODO: