]> git.donarmstrong.com Git - lilypond.git/commitdiff
* input/regression/beam-quant-standard.ly: new file: test standard
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 4 Jul 2004 22:23:28 +0000 (22:23 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 4 Jul 2004 22:23:28 +0000 (22:23 +0000)
beam quants.

* scm/beam.scm (check-quant-callbacks): new function
(check-beam-quant): new function: check whether current beam
quants match argument.

* lily/beam-quanting.cc (score_forbidden_quants): fix problem with
forbidden quant for sitting (upstem)/hanging (downstem) on outer
staffline line.

ChangeLog
Documentation/topdocs/NEWS.texi
THANKS
input/regression/beam-quant-standard.ly [new file with mode: 0644]
lily/beam-quanting.cc
lily/grob-scheme.cc
lily/lexer.ll
lily/parser.yy
scm/beam.scm
scm/define-grobs.scm

index a9224f4c5f48ed892b7dc348ff90d2aea33efe6f..f9908737b53db621429f9fffbb4e062dae535e7f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
+2004-07-05  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+       * input/regression/beam-quant-standard.ly: new file: test standard
+       beam quants.
+
+       * scm/beam.scm (check-quant-callbacks): new function
+       (check-beam-quant): new function: check whether current beam
+       quants match argument.
+
+       * lily/beam-quanting.cc (score_forbidden_quants): fix problem with
+       forbidden quant for sitting (upstem)/hanging (downstem) on outer
+       staffline line.
+
 2004-07-04  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * lily/parser.yy (Generic_prefix_music_scm): add (scm,scm) music functions.
+
        * lily/note-collision.cc (do_shifts): align colliding notes to
        their leftmost note.
 
index 0d5adb215c4dd7825410c0e44e0eaa2d90fea174..11cbda4cd467c43587bce2917a76178bb7fbd4df 100644 (file)
@@ -8,7 +8,7 @@
 
 @itemize @bullet
 
-@item Collisions are now correctly aligned relative to notes in other staves.
+@item Colliding notes are now correctly aligned relative to notes in other staves.
 
 @item An experimental GNOME output backend is available for developers.
 It depends on several unreleased packages such as gnome-guile TLA and
diff --git a/THANKS b/THANKS
index 97fd22193d4d075f8acc83518a7d1e92693cdefd..595448a3abdb09aaab0f480823d8393738991046 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -23,13 +23,14 @@ BUG HUNTERS/SUGGESTIONS
 Dave Phillips
 David Bobroff
 David Brandon
+Heinz Stolba
+Kristof Bastiaensen
+Martin Norbäck
 Peter Rosenbeck
 Stephen Pollei
 Bertalan Fodor
 Thomas Scharlowski
 Yuval Harel
-Martin Norbäck
-Kristof Bastiaensen
 
 
 Release 2.2
diff --git a/input/regression/beam-quant-standard.ly b/input/regression/beam-quant-standard.ly
new file mode 100644 (file)
index 0000000..4bf8cdf
--- /dev/null
@@ -0,0 +1,66 @@
+\header {
+
+    texidoc = "This file tests a few standard beam quants."
+    
+}
+
+
+%
+% todo: make the check-quant function throw an error for incorrect quants
+%
+
+\paper  { raggedright = ##t }
+
+
+% 
+% #(ly:set-option 'debug-beam #t)
+
+assertquant =
+#(def-music-function (location l r) (pair? pair?)
+  (let* ((f (check-quant-callbacks l r)))
+   
+   #{
+   \override Beam #'position-callbacks = $f
+   #}
+   
+))
+  
+
+\relative {
+    \assertquant #'(1 . 0)  #'(1 . 0)
+    e8[ e]
+    e4 
+    e4 
+    \assertquant #'(2 . -1)  #'(2 . -1)
+    f8[ f]
+    e4 
+    e4 
+    \assertquant #'(2 . 0)  #'(2 . 0)
+    g8[ g]
+    e4 
+    e4 
+    \assertquant #'(2 . 1)  #'(2 . 1)
+    a8[ a]
+    e4 e4 e4
+    \once \override Beam #'inspect-quants = #'(2.2 . 2.2)
+    a8[ a]
+    e4 
+    e4 
+
+    \assertquant #'(0 . 1)  #'(1 . 0)
+    d8[ e]
+    e4 
+    e4 
+    \assertquant #'(1 . 0)  #'(1 . 1)
+    e8[ f]
+    e4 
+    e4 
+    \assertquant #'(2 . -1)  #'(2 . 0)
+    f8[ g]
+    e4 
+    e4 
+    \assertquant #'(2 . 0)  #'(2 . 1)
+    g8[ a]
+    e4 
+    e4 
+    }
index 25df72abb180a87e345a5ef6d1639b3f451191cc..fc4ff9810c9f59ec1949706fe128a05960f576fc 100644 (file)
@@ -476,8 +476,15 @@ Beam::score_forbidden_quants (Real yl, Real yr,
            This test is too weak; we should really check all lines.
           */
          Direction stem_dir = dirs[d];
-         Real gap1 =  y[d] - stem_dir * ((j-1) * beam_translation + thickness / 2 - slt/2 );
-         Real gap2 = y[d] - stem_dir * (j * beam_translation - thickness / 2 + slt/2);
+
+         /*
+           The 2.2 factor is to provide a little leniency for
+           borderline cases. If we do 2.0, then the upper outer line
+           will be in the gap of the (2,sit) quant, leading to a
+           false demerit.
+          */
+         Real gap1 =  y[d] - stem_dir * ((j-1) * beam_translation + thickness / 2 - slt/2.2 );
+         Real gap2 = y[d] - stem_dir * (j * beam_translation - thickness / 2 + slt/2.2);
 
          Interval gap;
          gap.add_point (gap1);
index ce1438f0649ffaf0197d813decee85090e950416..7e3c05f74d258371466a1dfb84f5128fb8406605 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  grob-scheme.cc --
+  grob-scheme.cc -- Scheme entry points for the grob datatype
 
   source file of the GNU LilyPond music typesetter
 
index 377e9f1e9b4561f69c1fd3d21e592342c992c7f5..7b517b90e647f0ea41a6b67d7a7f98d037be1b0a 100644 (file)
@@ -913,6 +913,10 @@ music_function_type (SCM func)
        {
                return MUSIC_FUNCTION_SCM_MUSIC;
        }
+       else if (type == ly_symbol2scm ("scm-scm"))
+       {
+               return MUSIC_FUNCTION_SCM_SCM;
+       }
        else if (type == ly_symbol2scm ("music-music"))
        {
                return MUSIC_FUNCTION_MUSIC_MUSIC;
@@ -932,7 +936,7 @@ music_function_type (SCM func)
        else
                {
                /* TODO: print location */
-               error ("Can not find sigature for music function.");
+               error ("Can not find signature for music function.");
                }
 
        return MUSIC_FUNCTION_SCM;
index 1c2712250f22af04678e7af9bd62604e53e9bd55..a0c2170b51a80ce26b1d09eea98d848c6fee3548 100644 (file)
@@ -353,6 +353,7 @@ or
 %token <scm> MUSIC_FUNCTION_MUSIC 
 %token <scm> MUSIC_FUNCTION_MUSIC_MUSIC 
 %token <scm> MUSIC_FUNCTION_SCM 
+%token <scm> MUSIC_FUNCTION_SCM_SCM 
 %token <scm> MUSIC_FUNCTION_SCM_MUSIC 
 %token <scm> MUSIC_FUNCTION_SCM_MUSIC_MUSIC 
 %token <scm> MUSIC_FUNCTION_SCM_SCM_MUSIC 
@@ -988,6 +989,11 @@ Generic_prefix_music_scm:
                $$ = scm_list_4 ($1, make_input (THIS->pop_spot ()), $3, $4->self_scm ());
                scm_gc_unprotect_object ($4->self_scm ());
        }
+       | MUSIC_FUNCTION_SCM_SCM {
+               THIS->push_spot (); 
+       }  embedded_scm embedded_scm {
+               $$ = scm_list_4 ($1, make_input (THIS->pop_spot ()), $3, $4);
+       }
        | MUSIC_FUNCTION_MUSIC_MUSIC {
                THIS->push_spot (); 
        }  Music  Music {
index d20458eb5364b5b6bd1b5a82268490b2e764ab37..ab79154115a50b1efca047dc211b4f737441f3e9 100644 (file)
       (dir-compare (/ (car total) (car count)) (/ (cdr total) (cdr count)))
       (dir-compare (car count) (cdr count))))
            
+
+(define ((check-beam-quant posl posr) beam)
+  "Check whether BEAM has POSL and POSR quants.  POSL are (POSITION
+. QUANT) pairs, where QUANT is -1 (hang), 0 (center), 1 (sit) or -2/ 2 (inter) 
+
+"
+  (let*
+      ((posns (ly:grob-property beam 'positions))
+       (thick (ly:grob-property beam 'thickness))
+       (paper (ly:grob-paper beam))
+       (lthick (ly:output-def-lookup paper 'linethickness))
+       (staff-thick lthick) ; fixme.
+       (quant->coord (lambda (p q)
+                      (if (= 2 (abs q))
+                          (+ p (/ q 4.0))
+                          (+ p (- (* 0.5 q thick) (* 0.5 q lthick))))))
+       (want-l (quant->coord (car posl) (cdr posl))) 
+       (want-r (quant->coord (car posr) (cdr posr)))
+       (almost-equal (lambda (x y) (< (abs (- x y)) 1e-3))))
+    
+    (if (or (not (almost-equal want-l (car posns)))
+           (not (almost-equal want-r (cdr posns))))
+       (ly:warn
+        (format "Error in beam quanting found. Want (~S,~S) found (~S)."
+                want-l want-r posns
+                )))))
+                
+(define-public (check-quant-callbacks l r)
+  (list Beam::least_squares
+    Beam::check_concave
+    Beam::slope_damping
+    Beam::shift_region_to_valid
+    Beam::quanting
+    (check-beam-quant l r)
+    ))
+
+  
index dfedef5caabbebf5b7674dfa0cb6757e58d787eb..8d18393e7c296811bf5e74cb74ea3143ea82123e 100644 (file)
 
        ;; FIXME this should come from 'lengths
 
-;      (beamed-lengths . (3.26 3.26 1.5))
-       (beamed-lengths . (3.5 3.5 3.5 4.5 5.0))
+       (beamed-lengths . (3.26 3.26 1.5))
+;      (beamed-lengths . (3.5 3.5 3.5 4.5 5.0))
        
        ;; We use the normal minima as minimum for the ideal lengths,
        ;; and the extreme minima as abolute minimum length.