From dcf803f51a8621e64670930f89e9e02d845fe598 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 12 Sep 2004 12:27:23 +0000 Subject: [PATCH] * lily/beam.cc (set_minimum_dy): new function. Round non-zero small slope up to smallest quant. This prevents small slopes from getting rounded to zero. * lily/beam-quanting.cc (quanting): don't allow dy_mus slopes that are smaller than the smallest quant. * scm/define-grobs.scm (all-grob-descriptions): fix order of key-cancellation. This fixes: morgenlied.ly and input/regression/beam-concave.ly --- ChangeLog | 7 +++ input/les-nereides.ly | 1 + input/regression/beam-quant-standard.ly | 73 ++++++++++++++++++++++--- lily/beam-quanting.cc | 6 +- lily/beam.cc | 34 +++++++++++- scm/define-grobs.scm | 3 +- 6 files changed, 109 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0445e8900e..7899fe030e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2004-09-12 Han-Wen Nienhuys + * lily/beam.cc (set_minimum_dy): new function. Round non-zero + small slope up to smallest quant. This prevents small slopes from + getting rounded to zero. + + * lily/beam-quanting.cc (quanting): don't allow dy_mus slopes that + are smaller than the smallest quant. + * input/tutorial/brahms*.ly: remove. * input/*: update all .ly files. diff --git a/input/les-nereides.ly b/input/les-nereides.ly index a20d14aef4..7e155716c2 100644 --- a/input/les-nereides.ly +++ b/input/les-nereides.ly @@ -302,3 +302,4 @@ theScore = \score{ %%% LilyPond-indent-level:4 %%% End: %% new-chords-done %% +m diff --git a/input/regression/beam-quant-standard.ly b/input/regression/beam-quant-standard.ly index 942fbbcee6..c6d2f8d387 100644 --- a/input/regression/beam-quant-standard.ly +++ b/input/regression/beam-quant-standard.ly @@ -6,21 +6,22 @@ \version "2.3.16" -% -% todo: make the check-quant function throw an error for incorrect quants -% - \paper { raggedright = ##t #(define debug-beam-quanting #t) } -filler = \relative { e4 e } +filler = \new Voice \relative { + \hideNotes + e4 e +} % - +%% +%% Ross p108--112 primes = \relative { + \time 3/4 \assertBeamQuant #'(0 . 0) #'(0 . 0) c8[ c] \filler @@ -48,13 +49,30 @@ primes = \relative { a8[ a] \filler +%{ \once \override Beam #'inspect-quants = #'(2.2 . 2.2) + \assertBeamQuant a8[ a] \filler + +%} + } + seconds = \relative { - \assertBeamQuant #'(0 . 1) #'(0 . 1) + + \assertBeamQuant #'(0 . 0) #'(0 . 1) + a8[ b] + \filler + + + \assertBeamQuant #'(0 . 0) #'(0 . 1) + b8[ c] + \filler + + + \assertBeamQuant #'(0 . 0) #'(0 . 1) c8[ d] \filler @@ -82,6 +100,45 @@ seconds = \relative { \filler } +filler = \new Voice \relative { + \hideNotes + e4 e4. +} + +% Ross, p122 +primeSixteenths = \relative { + \stemUp + \assertBeamQuant #'(0 . -1) #'(0 . -1) + g16[ g] + \filler + \assertBeamQuant #'(0 . -1) #'(0 . -1) + a16[ a] + \filler + \assertBeamQuant #'(0 . -1) #'(0 . -1) + b16[ b] + \filler + \assertBeamQuant #'(0 . 0) #'(0 . 0) + c16[ c] + \filler + \assertBeamQuant #'(1 . -1) #'(1 . -1) + d16[ d] + \filler + \assertBeamQuant #'(1 . 0) #'(1 . 0) + e16[ e] + \filler + \assertBeamQuant #'(2 . -1) #'(2 . -1) + f16[ f] + \filler + \assertBeamQuant #'(2 . 0) #'(2 . 0) + g16[ g] + \filler + \assertBeamQuant #'(3 . -1) #'(3 . -1) + a16[ a] + \filler + \assertBeamQuant #'(3 . 0) #'(3 . 0) + b16[ b] + \filler +} -{ \primes \seconds } +{ \primes \seconds \primeSixteenths } diff --git a/lily/beam-quanting.cc b/lily/beam-quanting.cc index 6a8721fdca..7dea607660 100644 --- a/lily/beam-quanting.cc +++ b/lily/beam-quanting.cc @@ -106,14 +106,14 @@ Beam::quanting (SCM smob) Real thickness = Beam::get_thickness (me) / ss ; Real slt = Staff_symbol_referencer::line_thickness (me) / ss; - SCM sdy = me->get_property ("least-squares-dy"); - Real dy_mus = scm_is_number (sdy) ? scm_to_double (sdy) : 0.0; - + Real dy_mus = robust_scm2double (me->get_property ("least-squares-dy"), 0); Real straddle = 0.0; Real sit = (thickness - slt) / 2; Real inter = 0.5; Real hang = 1.0 - (thickness - slt) / 2; Real quants [] = {straddle, sit, inter, hang }; + + int num_quants = int (sizeof (quants)/sizeof (Real)); Array quantsl; diff --git a/lily/beam.cc b/lily/beam.cc index d8648dc26c..9b71b10331 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -836,6 +836,29 @@ Beam::position_beam (Grob *me) } +void +set_minimum_dy (Grob *me, Real * dy) +{ + if (*dy) + { + /* + If dy is smaller than the smallest quant, we + get absurd direction-sign penalties. + */ + + Real ss = Staff_symbol_referencer::staff_space (me); + Real thickness = Beam::get_thickness (me) / ss ; + Real slt = Staff_symbol_referencer::line_thickness (me) / ss; + Real sit = (thickness - slt) / 2; + Real inter = 0.5; + Real hang = 1.0 - (thickness - slt) / 2; + + *dy = sign (*dy) * (fabs (*dy) + >? + (sit set_property ("least-squares-dy", scm_make_real (dy)); pos = Interval (y, (y+dy)); } @@ -954,10 +979,10 @@ Beam::least_squares (SCM smob) We can't combine with previous function, since check concave and slope damping comes first. -TODO: we should use the concaveness to control the amount of damping -applied. + TODO: we should use the concaveness to control the amount of damping + applied. - */ +*/ MAKE_SCHEME_CALLBACK (Beam, shift_region_to_valid, 1); SCM Beam::shift_region_to_valid (SCM grob) @@ -1091,6 +1116,9 @@ Beam::slope_damping (SCM smob) slope = 0.6 * tanh (slope) / (damping + concaveness); Real damped_dy = slope * dx; + + set_minimum_dy (me, &damped_dy); + pos[LEFT] += (dy - damped_dy) / 2; pos[RIGHT] -= (dy - damped_dy) / 2; diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 7ce7c91608..80210c8ba9 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -1028,13 +1028,14 @@ ;; FIXME this should come from 'lengths - (beamed-lengths . (3.26 3.26 1.5)) + (beamed-lengths . (3.26 3.5 3.6)) ;; We use the normal minima as minimum for the ideal lengths, ;; and the extreme minima as abolute minimum length. ;; The 'normal' minima (beamed-minimum-free-lengths . (1.83 1.5 1.25)) + ;(beamed-minimum-free-lengths . (2.0 1.83 1.25)) ;; The 'extreme case' minima (beamed-extreme-minimum-free-lengths . (2.0 1.25)) -- 2.39.5