From dacf1d3839929e0e89b7df14bebc46f4ddb6d6e1 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 13 Jun 2006 10:42:29 +0000 Subject: [PATCH] (best_splitpoint_index): fix beaming patterns for 16th triplets. --- ChangeLog | 8 +++++++ THANKS | 3 ++- input/regression/beaming.ly | 9 +++++--- lily/beaming-pattern.cc | 39 ++++++++++++++++++++++++++++------ scm/define-markup-commands.scm | 10 ++++++--- 5 files changed, 55 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 34ad37fb06..c125b3fc40 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-06-13 Han-Wen Nienhuys + + * lily/beaming-pattern.cc (best_splitpoint_index): fix beaming + patterns for 16th triplets. + 2006-06-10 Graham Percival * Documentation/user/ page.itely, global.itely: editing @@ -25,6 +30,9 @@ 2006-06-10 Han-Wen Nienhuys + * scm/define-markup-commands.scm (wordwrap-markups): use + output-def 'line-width if undefined. + * HACKING: trim outdated info. 2006-06-09 Mats Bengtsson diff --git a/THANKS b/THANKS index c44741fb8e..f2f6118f9d 100644 --- a/THANKS +++ b/THANKS @@ -5,7 +5,6 @@ DEVELOPMENT TEAM Han-Wen Nienhuys - Core development Jan Nieuwenhuizen - Core development -Pedro Kroger - Build Meister Graham Percival - Documentation Editor Mats Bengtsson - Support Guru @@ -24,8 +23,10 @@ Trevor Bača Andrew Sidwell Chris Sawer Jamie Bullock +Michael Meixner Steve Doonan Trent Johnston +Vivian Barty-Taylor DOCUMENTATION HELPERS diff --git a/input/regression/beaming.ly b/input/regression/beaming.ly index 09dc8938f1..b2507a433f 100644 --- a/input/regression/beaming.ly +++ b/input/regression/beaming.ly @@ -4,12 +4,15 @@ \header{ texidoc=" Beaming is generated automatically. Beams may cross bar lines. In that -case, line breaks are forbidden. Yet clef and key signatures are -hidden just as with breakable bar lines. +case, line breaks are forbidden. " } \context Staff \relative c'' { + + c8[ \times 2/3 { c16 d e] } + s4*3 + c8.[ c16] c8.[ c16 c8. c16] c16[ c8.] | @@ -22,7 +25,7 @@ hidden just as with breakable bar lines. c32 c2 - c8[ c c] c8 % over barline + c8[^"over barline" c c] c8 c16[ c8 c16] c32[ c16 c16 c16 c32] c32[ c16 c8 c32] % hmm ? diff --git a/lily/beaming-pattern.cc b/lily/beaming-pattern.cc index f48faadc56..b6e5a36e51 100644 --- a/lily/beaming-pattern.cc +++ b/lily/beaming-pattern.cc @@ -24,6 +24,20 @@ Beam_rhythmic_element::Beam_rhythmic_element (Moment m, int i) beam_count_drul_[RIGHT] = i; } + +int +count_factor_twos (int x) +{ + int c = 0; + while (x && x % 2) + { + x /= 2; + c ++; + } + + return c; +} + int Beaming_pattern::best_splitpoint_index (bool *at_boundary) const { @@ -42,16 +56,27 @@ Beaming_pattern::best_splitpoint_index (bool *at_boundary) const *at_boundary = false; - int min_denominator = INT_MAX; + int min_factor_twos = INT_MAX; int min_index = -1; Moment beat_pos; for (vsize i = 1; i < infos_.size (); i++) { - Moment dt = infos_[i].start_moment_ - infos_[i].beat_start_; - if (dt.den () < min_denominator) + Moment dt = infos_[i].start_moment_ - infos_[i].beat_start_; + + /* + This is a kludge, for the most common case of 16th, 32nds + etc. What should really happen is that \times x/y should + locally introduce a voice-specific beat duration. (or + perhaps: a list of beat durations for nested tuplets.) + + */ + + int factor_2s = count_factor_twos (dt.den ()); + + if (factor_2s < min_factor_twos) { - min_denominator = dt.den (); + min_factor_twos = factor_2s; min_index = i; } } @@ -79,7 +104,7 @@ Beaming_pattern::beamify (Context *context) bool subdivide_beams = to_boolean (context->get_property ("subdivideBeams")); Moment beat_length = robust_scm2moment (context->get_property ("beatLength"), Moment (1, 4)); - Moment measure_length = robust_scm2moment (context->get_property ("beatLength"), Moment (1, 4)); + Moment measure_length = robust_scm2moment (context->get_property ("measureLength"), Moment (1, 4)); if (infos_[0].start_moment_ < Moment (0)) for (vsize i = 0; i < infos_.size(); i++) @@ -112,13 +137,13 @@ Beaming_pattern::beamify (Context *context) vsize k = 0; for (vsize i = 0; i < infos_.size(); i++) { - while (j < group_starts.size()-1 + while (j < group_starts.size() - 1 && group_starts[j+1] <= infos_[i].start_moment_) j++; infos_[i].group_start_ = group_starts[j]; - while (k < beat_starts.size()-1 + while (k < beat_starts.size() - 1 && beat_starts[k+1] <= infos_[i].start_moment_) k++; diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index 83c5750010..d450ec2468 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -330,8 +330,10 @@ gsave /ecrm10 findfont (text-width (apply + text-widths)) (text-dir (chain-assoc-get 'text-direction props RIGHT)) (word-count (length stencils)) - (word-space (chain-assoc-get 'word-space props)) - (line-width (chain-assoc-get 'line-width props)) + (word-space (chain-assoc-get 'word-space props 1)) + (prop-line-width (chain-assoc-get 'line-width props #f)) + (line-width (if prop-line-width prop-line-width + (ly:output-def-lookup layout 'line-width))) (fill-space (cond ((= word-count 1) @@ -464,7 +466,9 @@ determines the space between each markup in @var{args}." (define (wordwrap-markups layout props args justify) (let* ((baseline-skip (chain-assoc-get 'baseline-skip props)) - (line-width (chain-assoc-get 'line-width props)) + (prop-line-width (chain-assoc-get 'line-width props #f)) + (line-width (if prop-line-width prop-line-width + (ly:output-def-lookup layout 'line-width))) (word-space (chain-assoc-get 'word-space props)) (text-dir (chain-assoc-get 'text-direction props RIGHT)) (lines (wordwrap-stencils -- 2.39.5