Re: unwanted randomness while generating LilyPond output

2024-02-20 Thread Carl Sorensen
On Mon, Feb 19, 2024 at 1:28 PM Michael Käppler  wrote:

> 
> This patch will print the page stencils as pretty-printed scheme code to
> stdout, while
> normal messages go to stderr.
>
> * run `lilypond --eps input.ly > epsdebug.log`
>
> * send me the resulting log files
>
>
The patch did not apply (perhaps due to line endings), but I was able to
make the changes manually.

I've attached the log.

HTH,

Carl


epsdebug.log
Description: Binary data


Re: unwanted randomness while generating LilyPond output

2024-02-19 Thread Carl Sorensen
On Mon, Feb 19, 2024 at 1:28 PM Michael Käppler  wrote:

> Hello Werner,
> thanks for your reply!
>
> Just to make sure we're on the same page: You don't assume that there is
> variability across
> different runs of the same LilyPond build on the same machine? (Aka some
> kind of "non-deterministic behaviour")
> That would be my understanding of "randomness", which I find a bit of a
> misleading term here.
>

I don't think that we have any evidence that different runs on the same
machine produce different output.

As far as I know, we only  have evidence that Werner's computer produced a
different file than my computer when we were both using the same commit of
LilyPond (but we have different operating systems, and different versions
of all of the OS tools).


> FWIW, I can confirm that 100 subsequent runs of `lilypond --eps
> input.ly` on my machine
> produce exactly bit-identical eps files.
>
> Carl and Werner, could you please:
>
> * patch scm/framework-ps.scm with the attached patch (go to the
> directory where framework-ps.scm resides
> and run `patch < epsdebug.patch`)
>

I will try to make this happen tomorrow.


>
> (Does not have to be in the source tree, you can also do a backup of
> framework-ps.scm and patch your working installation)
>
> This patch will print the page stencils as pretty-printed scheme code to
> stdout, while
> normal messages go to stderr.
>
> * run `lilypond --eps input.ly > epsdebug.log`
>
> * send me the resulting log files
>

Carl


Re: unwanted randomness while generating LilyPond output

2024-02-19 Thread Michael Käppler

Hello Werner,
thanks for your reply!

Just to make sure we're on the same page: You don't assume that there is
variability across
different runs of the same LilyPond build on the same machine? (Aka some
kind of "non-deterministic behaviour")
That would be my understanding of "randomness", which I find a bit of a
misleading term here.

FWIW, I can confirm that 100 subsequent runs of `lilypond --eps
input.ly` on my machine
produce exactly bit-identical eps files.

Carl and Werner, could you please:

* patch scm/framework-ps.scm with the attached patch (go to the
directory where framework-ps.scm resides
and run `patch < epsdebug.patch`)

(Does not have to be in the source tree, you can also do a backup of
framework-ps.scm and patch your working installation)

This patch will print the page stencils as pretty-printed scheme code to
stdout, while
normal messages go to stderr.

* run `lilypond --eps input.ly > epsdebug.log`

* send me the resulting log files

Michael

Am 17.02.2024 um 08:05 schrieb Werner LEMBERG:

Hello Michael,


sorry for the late reply.


I would like to help debugging the problem. Which exact invocation
do I have to use to replicate the EPS files you sent?

This is due to using `extractpdfmark`, which makes the build add the
options

```
-dfont-ps-resdir=$(top-build-dir)/out-fonts -O TeX-GS
```

However,...


If I do `lilypond --eps input.ly` I get a much bigger EPS file, that
seemingly has the fonts attached as binary data.

... it doesn't matter for the problem at hand: you also get the
differences with normal `lilypond --eps` calls.


 Werner
--- framework-ps.scm.bakMon Feb 19 19:45:40 2024
+++ framework-ps.scmMon Feb 19 20:10:30 2024
@@ -22,6 +22,7 @@
 (use-modules (ice-9 string-fun)
  ((ice-9 iconv) #:select (bytevector->string string->bytevector))
  (ice-9 match)
+ (ice-9 pretty-print)
  (guile)
  (lily page)
  (lily paper-system)
@@ -829,6 +830,7 @@
 (write-preamble paper load-fonts port)
 (display "/mark_page_link { pop pop pop pop pop } bind def\n" port)
 (display "gsave set-ps-scale-to-lily-scale\n" port)
+(pretty-print (ly:stencil-expr dump-me))
 (ly:outputter-dump-stencil outputter dump-me)
 (display "stroke grestore\n%%Trailer\n%%EOF\n" port)
 (ly:outputter-close outputter)
%% Generated by lilypond-book
%% Options: [exampleindent=10.16\mm,indent=0\mm,line-width=160\mm,paper-height=845.047\pt,paper-width=597.508\pt,papersize='(cons (* 597.508 pt) (* 845.047 pt))]
\include "lilypond-book-preamble.ly"


% 
% Start cut-&-pastable-section
% 

#(ly:set-option 'eps-box-padding 3.00)



\paper {
  #(set-paper-size '(cons (* 597.508 pt) (* 845.047 pt)))
  indent = 0\mm
  line-width = 160\mm
  % offset the left padding, also add 1mm as lilypond creates cropped
  % images with a little space on the right
  line-width = #(- line-width (* mm  3.00) (* mm 1))
}

\layout {
  
}




% 
% ly snippet:
% 
\sourcefilename "snippets/adding-a-figured-bass-above-or-below-the-notes.ly"
\sourcefileline 0
%% DO NOT EDIT this file manually; it was automatically
%% generated from the LilyPond Snippet Repository
%% (http://lsr.di.unimi.it).
%%
%% Make any changes in the LSR itself, or in
%% `Documentation/snippets/new/`, then run
%% `scripts/auxiliar/makelsr.pl`.
%%
%% This file is in the public domain.

\version "2.24.0"

\header {
  lsrtags = "ancient-notation, chords, contexts-and-engravers"

  texidoc = "
When writing a figured bass, you can place the figures above or below
the bass notes, by defining the
@code{BassFigureAlignmentPositioning.direction} property (exclusively
in a @code{Staff} context). Choices are @code{#UP} (or @code{#1}),
@code{#CENTER} (or @code{#0}) and @code{#DOWN} (or @code{#-1}).

This property can be changed as many times as you wish. Use
@code{\\once \\override} if you don't want the override to apply to the
whole score.
"

  doctitle = "Adding a figured bass above or below the notes"
} % begin verbatim


bass = {
  \clef bass
  g4 b, c d
  e d8 c d2
}

continuo = \figuremode {
  <_>4 <6>4 <5/>4
  \override Staff.BassFigureAlignmentPositioning.direction = #UP
  %\bassFigureStaffAlignmentUp
  < _+ >4 <6>
  \set Staff.useBassFigureExtenders = ##t
  \override Staff.BassFigureAlignmentPositioning.direction = #DOWN
  %\bassFigureStaffAlignmentDown
  <4>4. <4>8 <_+>4
}

\score {
  <<
\new Staff = bassStaff \bass
\context Staff = bassStaff \continuo
  >>
}



% 
% end ly snippet
% 


Re: unwanted randomness while generating LilyPond output

2024-02-16 Thread Werner LEMBERG


Hello Michael,


sorry for the late reply.

> I would like to help debugging the problem. Which exact invocation
> do I have to use to replicate the EPS files you sent?

This is due to using `extractpdfmark`, which makes the build add the
options

```
-dfont-ps-resdir=$(top-build-dir)/out-fonts -O TeX-GS
```

However,...

> If I do `lilypond --eps input.ly` I get a much bigger EPS file, that
> seemingly has the fonts attached as binary data.

... it doesn't matter for the problem at hand: you also get the
differences with normal `lilypond --eps` calls.


Werner



Re: unwanted randomness while generating LilyPond output

2024-02-12 Thread Michael Käppler

Hi Werner,
I would like to help debugging the problem. Which exact invocation do I
have to use
to replicate the EPS files you sent?
If I do `lilypond --eps input.ly` I get a much bigger EPS file, that
seemingly has the
fonts attached as binary data.

Michael

Am 09.02.2024 um 09:11 schrieb Werner LEMBERG:

Carl sent me his complete build (thanks!) for further investigation of
differences, and this unveiled an unpleasant surprise: We have
randomness in the construction of LilyPond EPS files.

I'm attaching an EPS output of both Carl's and my own build, together
with the corresponding source file; as can be seen, the EPS files
differ (I've checked that they display exactly the same).

Any idea how to fix this?  The randomness itself isn't bad, but it
makes it much harder to find problems, and it might prevent
reproducible documentation builds.  I suppose that somewhere in the
SCM code we need to sort a list or something like that while
generating output...


 Werner