Hi,

i have encountered an error when working with new ambitus code (
http://codereview.appspot.com/4609041/): i did some modifications (Rietveld
patch sets 1-3) and everything worked fine, source compiled without any
problems. But when i made more changes, saved them in working directory and
tried to compile, make exited with an error:

[<string>]
[<string>]
[<string>]]
  [/home/janek/lilypond-git/ly/property-init.ly]
  [/home/janek/lilypond-git/ly/grace-init.ly]
  [/home/janek/lilypond-git/ly/midi-init.ly
   [/home/janek/lilypond-git/ly/performer-init.ly]]
  [/home/janek/lilypond-git/ly/paper-defaults-init.ly
   [/home/janek/lilypond-git/ly/titling-init.ly]]
  [/home/janek/lilypond-git/ly/engraver-init.ly]]
 [/home/janek/lilypond-git/ly/generate-documentation.ly
[/home/janek/lilypond-git/build/out/share/lilypond/current/scm/documentation-lib.scm]
[/home/janek/lilypond-git/build/out/share/lilypond/current/scm/lily-sort.scm]
[/home/janek/lilypond-git/build/out/share/lilypond/current/scm/document-functions.scm]
[/home/janek/lilypond-git/build/out/share/lilypond/current/scm/document-translation.scm]
[/home/janek/lilypond-git/build/out/share/lilypond/current/scm/document-music.scm]
[/home/janek/lilypond-git/build/out/share/lilypond/current/scm/document-type-predicates.scm]
[/home/janek/lilypond-git/build/out/share/lilypond/current/scm/document-identifiers.scm]
[/home/janek/lilypond-git/build/out/share/lilypond/current/scm/document-backend.scm]
[/home/janek/lilypond-git/build/out/share/lilypond/current/scm/document-markup.scm]
Writing "internals.texi"...ERROR: In procedure procedure-name:
ERROR: Wrong type argument in position 1: #f
make[1]: *** [out/internals.texi] Error 1
make[1]: Leaving directory `/home/janek/lilypond-git/build/Documentation'
make: *** [all] Error 2

When i reverted these new changes and tried to compile the code that used to
compile without problems, i got the same error! Even 'make clean' didn't
help. Finally, with some combination of 'make clean' and switching between
git master and different commits, it compiled again, and after more struggle
i got the new code (the one that first introduced the error in make) to
compile too!
I haven't noticed any logical reasons why sometimes it fails and sometimes
not.
If you have any ideas, please advice.
An explanation of the error above would be nice, too :)
I attach patches if you want to test it.

cheers,
Janek
From 9dc1be9f96ac50ec8ccd6f1b7ac570fd91c74a80 Mon Sep 17 00:00:00 2001
From: Janek Warchol <[email protected]>
Date: Mon, 13 Jun 2011 00:34:45 +0200
Subject: [PATCH 1/2] ambitus: special handling of small ambits' lines

Until now, it was not possible to have all ambits
look good: either the gaps between ambit line
and heads were too big for ambits of 4th and 5th,
or they were too small for other ambits.
This patch introduces automatic scaling
of the gap between heads and line: bigger ambits
are left unchanged, but smaller have their gap
diminished so that the line is long enough.

ambitus: rewriting comments
---
 scm/output-lib.scm |   28 ++++++++++++++++++++++++++--
 1 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/scm/output-lib.scm b/scm/output-lib.scm
index 1081377..647eb4f 100644
--- a/scm/output-lib.scm
+++ b/scm/output-lib.scm
@@ -910,6 +910,20 @@ between the two text elements."
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; ambitus
 
+;; We need to calculate the gaps between ambitus line and ambitus heads:
+;; Property AmbitusLine #'gap is our starting point (a "default value")
+;; and we adjust it to fit small ambituses better.
+;;
+;; We calculate a theoretical gap size using a linear function.
+;; The function was determined by trial-and-error; it's main premises are:
+;; - smaller distance between heads means smaller gap,
+;; - don't force te gap to be too small if the default value is big
+;; - for small default values gap shouldn't reach 0 too fast.
+;;
+;; Then we quant the value (steps: 0.2 0.45 0.7 0.95 1.2 ...)
+;; and check if the result is neither too big or too small
+;; compared to the property value which we began with.
+
 (define-public (ambitus::print grob)
   (let ((heads (ly:grob-object grob 'note-heads)))
 
@@ -918,13 +932,23 @@ between the two text elements."
 	(let* ((common (ly:grob-common-refpoint-of-array grob heads Y))
 	       (head-down (ly:grob-array-ref heads 0))
 	       (head-up (ly:grob-array-ref heads 1))
-	       (gap (ly:grob-property grob 'gap 0.35))
+	       (ground (interval-end (ly:grob-extent head-down common Y)))
+	       (roof (interval-start (ly:grob-extent head-up common Y)))
+	       (space-between-heads (- roof ground))
+	       (gap-property (ly:grob-property grob 'gap 0.35))
+	       (linear-gap (+ (max gap-property 0.3) -0.45
+	                      (* 0.2 space-between-heads)))
+	       (quanted-gap (+ (* (floor (/ (- linear-gap 0.2) 0.25)) 0.25) 0.2))
+	       ;; we don't want to quant gap values smaller than 0.2
+	       ;; (because quanting them would mean making them 0).
+	       (calculated-gap (if (< linear-gap 0.2) linear-gap quanted-gap))
+	       (gap (max (min calculated-gap gap-property) (/ gap-property 4.5)))
 	       (point-min (+ (interval-end (ly:grob-extent head-down common Y))
 			     gap))
 	       (point-max (- (interval-start (ly:grob-extent head-up common Y))
 			     gap)))
 
-	  (if (< point-min point-max)
+	  (if (< (+ point-min 0.1) point-max) ; don't print lines shorter than 0.1
 	      (let* ((layout (ly:grob-layout grob))
 		     (line-thick (ly:output-def-lookup layout 'line-thickness))
 		     (blot (ly:output-def-lookup layout 'blot-diameter))
-- 
1.7.0.4

From ac842a905938a8fc5ce8227c203e3190573727c3 Mon Sep 17 00:00:00 2001
From: Janek Warchol <[email protected]>
Date: Wed, 15 Jun 2011 00:42:17 +0200
Subject: [PATCH 2/2] controlling the amount of correction

---
 scm/define-grobs.scm |    1 +
 scm/output-lib.scm   |    8 +++++++-
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index ecfeee3..61507ea 100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -138,6 +138,7 @@
     (AmbitusLine
      . (
 	(gap . 0.35)
+	(woot . 1)
 	(stencil . ,ambitus::print)
 	(thickness . 2)
 	(X-offset . ,ly:self-alignment-interface::centered-on-x-parent)
diff --git a/scm/output-lib.scm b/scm/output-lib.scm
index 647eb4f..fade876 100644
--- a/scm/output-lib.scm
+++ b/scm/output-lib.scm
@@ -923,6 +923,10 @@ between the two text elements."
 ;; Then we quant the value (steps: 0.2 0.45 0.7 0.95 1.2 ...)
 ;; and check if the result is neither too big or too small
 ;; compared to the property value which we began with.
+;;
+;; Finally we check if the user wanted us to do this correction at all
+;; (AmbitusLine #'woot = 0 means "he didn't" and woot = 1 means
+;; "yes, please". intermediate values are accepted).
 
 (define-public (ambitus::print grob)
   (let ((heads (ly:grob-object grob 'note-heads)))
@@ -936,13 +940,15 @@ between the two text elements."
 	       (roof (interval-start (ly:grob-extent head-up common Y)))
 	       (space-between-heads (- roof ground))
 	       (gap-property (ly:grob-property grob 'gap 0.35))
+	       (woot (ly:grob-property grob 'woot 1))
 	       (linear-gap (+ (max gap-property 0.3) -0.45
 	                      (* 0.2 space-between-heads)))
 	       (quanted-gap (+ (* (floor (/ (- linear-gap 0.2) 0.25)) 0.25) 0.2))
 	       ;; we don't want to quant gap values smaller than 0.2
 	       ;; (because quanting them would mean making them 0).
 	       (calculated-gap (if (< linear-gap 0.2) linear-gap quanted-gap))
-	       (gap (max (min calculated-gap gap-property) (/ gap-property 4.5)))
+	       (unwooted (max (min calculated-gap gap-property) (/ gap-property 4.5)))
+	       (gap (+ (* unwooted woot) (* gap-property (- 1 woot))))
 	       (point-min (+ (interval-end (ly:grob-extent head-down common Y))
 			     gap))
 	       (point-max (- (interval-start (ly:grob-extent head-up common Y))
-- 
1.7.0.4

_______________________________________________
lilypond-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to