Re: Page turning in song book: Only \scores with more than 1 page should be forced to start on even page number

2023-02-26 Thread Wol

On 24/02/2023 20:34, Johannes Maibaum wrote:

I wanted to ask if it would be possible to improve the page-turn-
breaking algorithm for the case where the user also has ragged-bottom
set to #t (which you correctly assumed I was trying to use as well).


If we're looking at demerits for page-breaking, can that be 
user-tweaked? You know I moan about page-breaking, and would usually 
much prefer to take a hit in readability than have to turn a page.


Lilypond usually doesn't pack stuff precisely to make it easily 
readable, but if that means a page turn outside on a windy day... 
jacking it up to force one or even two systems onto the previous page 
would be brilliant.


Cheers,
Wol



Re: Page turning in song book: Only \scores with more than 1 page should be forced to start on even page number

2023-02-26 Thread Johannes Maibaum
Hello Valentin,

I was trying your patch (attached, for reference) on a self-built
lilypond today. It does indeed help with my use case (ragged-bottom =
##t), so thanks for that. I would appreciate if this patch could be
included in lilypond.

The only exception is when there is a song with more than 1 page
directly following a 1-page song where the latter started on an even
page. In this case, the last line of the 1-page song is still put on the
odd page so that the "more-pages" song can start on the next even page.

I would prefer a blank page (or a "This page is intentionally left
blank." page) in this case, instead of tearing apart the short song on
the page before.

For this I have for now added an empty \markup{} after all scores as a
work-around. I.e. if lilypond wants to put something on the odd page, it
will put the empty \markup{} on the odd page.

Is there a better solution? I tried experimenting with \if (to show
"This page is intentionally left blank" only if I set a custom variable
to ##t for a specific score), but I couldn't figure out how to make this
work.

> Am Donnerstag, dem 24.02.2022 um 00:43 +0100 schrieb Valentin Petzel:
> 
> > It might also be sensible to add a small demerit depending on the 
> > free whitespace to enforce a more even distribution of whitespace.

Since I am not a lilypond developer with knowledge about the internals,
I was not able to follow this suggestion. I did a look around in page-
turn-page-breaking.cc, but couldn't find a place where this demerit
would have to be added.

So, as it seems my limited knowledge about lilypond development will not
help in fixing the shortcomings from your patch, unfortunately.
Hopefully it could still be considered.


Thanks & Best,
Johannes
From 76700c375f7f1d04527395ce2e5a745744e14667 Mon Sep 17 00:00:00 2001
From: Valentin Petzel 
Date: Thu, 24 Feb 2022 00:43:07 +0100
Subject: [PATCH] page-turn-breaking: Add small demerit for more pages

---
 lily/page-turn-page-breaking.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lily/page-turn-page-breaking.cc b/lily/page-turn-page-breaking.cc
index 28a65c66df..eba0a537c2 100644
--- a/lily/page-turn-page-breaking.cc
+++ b/lily/page-turn-page-breaking.cc
@@ -126,7 +126,7 @@ Page_turn_page_breaking::put_systems_on_pages (vsize start, vsize end,
   ret.system_count_ = result.systems_per_page_;
 
   ret.too_many_lines_ = all_lines_stretched (configuration);
-  ret.demerits_ = result.demerits_;
+  ret.demerits_ = result.demerits_ + static_cast(ret.page_count_) / 1000;
   if (start > 0)
 ret.demerits_ += state_[start - 1].demerits_;
 
-- 
2.39.2



Re: Page turning in song book: Only \scores with more than 1 page should be forced to start on even page number

2023-02-24 Thread Johannes Maibaum
Hello Valentin,

returning here after another year (and what a year...).

I wanted to ask if it would be possible to improve the page-turn-
breaking algorithm for the case where the user also has ragged-bottom
set to #t (which you correctly assumed I was trying to use as well).

Am Donnerstag, dem 24.02.2022 um 00:43 +0100 schrieb Valentin Petzel:
> Hello Johannes,
> 
> using page-turn-breaking only acts like this if ragged-bottom is set to #t 
> (which should be considered as weird behaviour). I suppose what’s happening 
> there is that with ragged-bottom set to #t there is no demerit for short 
> pages, as the pages are not stretched out (which is the thing that would get 
> demerits). This means that there is no demerit to breaking in every possible 
> place, which I think is one of the first solutions tried by the breaking 
> algorithm. Thus even if we find a shorter solution of equal demerit we won’t 
> use it.
> 
> I’d suggest we should add a very small demerit for solutions with lots of 
> pages so that with configurations with the same overall demerit the one with 
> less pages is preferred.
> 
> E.g. changing line 124 in page-turn-page-breaking.cc to
> ret.demerits_ = result.demerits_ + static_cast(ret.page_count_)/1000;
> we do already get better behaviour (although probably not the best, for some 
> weird reason it allows compression of pages when it is not nescessary, like 
> here

Would this be line 129 today, i.e. in
Page_turn_page_breaking::put_systems_on_pages()?

https://gitlab.com/lilypond/lilypond/-/blob/master/lily/page-turn-page-breaking.cc#L129

> 
> \paper {
>   page-breaking = #ly:page-turn-breaking
>   ragged-bottom = ##t
> }
> 
> {\repeat unfold 20 c1 }
> {\repeat unfold 20 c1 }
> {\repeat unfold 20 c1 }
> {\repeat unfold 40 c1 }
> {\repeat unfold 20 c1 }
> {\repeat unfold 100 c1 }
> {\repeat unfold 20 c1 }
> {\repeat unfold 20 c1 }
> {\repeat unfold 20 c1 }
> {\repeat unfold 20 c1 }
> {\repeat unfold 200 c1 }
> 
> on page 2). It might also be sensible to add a small demerit depending on the 
> free whitespace to enforce a more even distribution of whitespace.
> 
> Cheers,
> Valentin
> 
> Am Mittwoch, 23. Februar 2022, 18:13:15 CET schrieb Johannes Maibaum:
> > Hello,
> > 
> > I am working on a lead-sheet song book (i.e. one \book with many short
> > \scores inside), and I was looking for a way to optimize page turning
> > for musicians playing tunes from the book. Most songs fit on a single
> > page, but there are a few songs which span 2 or more pages.
> > 
> > I want to make sure that all songs which more than 1 page start on an
> > even page, but all 1-page songs should be allowed to start on an even or
> > an odd page.
> > 
> > Looking through the documentation, and testing the built-in page-
> > breaking algorithms, there doesn't seem to be a turn-key solution for my
> > use-case. The default optimal-breaking algorithm starts every \score on
> > the next page (even or odd), and page-turn-breaking forces every \score
> > to start on an even page, which causes (almost) blank pages (the last
> > line is put on the odd page) after all tunes which would happily fit on
> > 1 page.
> > 
> > I tried fiddling with the different blank-page-*-penalties, but so far I
> > wasn't able to achieve my goal. Is it possible after all?
> > 
> > 
> > Best,
> > Johannes
> 



Re: Page turning in song book: Only \scores with more than 1 page should be forced to start on even page number

2022-02-23 Thread Valentin Petzel
Hello Johannes,

using page-turn-breaking only acts like this if ragged-bottom is set to #t 
(which should be considered as weird behaviour). I suppose what’s happening 
there is that with ragged-bottom set to #t there is no demerit for short 
pages, as the pages are not stretched out (which is the thing that would get 
demerits). This means that there is no demerit to breaking in every possible 
place, which I think is one of the first solutions tried by the breaking 
algorithm. Thus even if we find a shorter solution of equal demerit we won’t 
use it.

I’d suggest we should add a very small demerit for solutions with lots of 
pages so that with configurations with the same overall demerit the one with 
less pages is preferred.

E.g. changing line 124 in page-turn-page-breaking.cc to
ret.demerits_ = result.demerits_ + static_cast(ret.page_count_)/1000;
we do already get better behaviour (although probably not the best, for some 
weird reason it allows compression of pages when it is not nescessary, like 
here

\paper {
  page-breaking = #ly:page-turn-breaking
  ragged-bottom = ##t
}

{\repeat unfold 20 c1 }
{\repeat unfold 20 c1 }
{\repeat unfold 20 c1 }
{\repeat unfold 40 c1 }
{\repeat unfold 20 c1 }
{\repeat unfold 100 c1 }
{\repeat unfold 20 c1 }
{\repeat unfold 20 c1 }
{\repeat unfold 20 c1 }
{\repeat unfold 20 c1 }
{\repeat unfold 200 c1 }

on page 2). It might also be sensible to add a small demerit depending on the 
free whitespace to enforce a more even distribution of whitespace.

Cheers,
Valentin

Am Mittwoch, 23. Februar 2022, 18:13:15 CET schrieb Johannes Maibaum:
> Hello,
> 
> I am working on a lead-sheet song book (i.e. one \book with many short
> \scores inside), and I was looking for a way to optimize page turning
> for musicians playing tunes from the book. Most songs fit on a single
> page, but there are a few songs which span 2 or more pages.
> 
> I want to make sure that all songs which more than 1 page start on an
> even page, but all 1-page songs should be allowed to start on an even or
> an odd page.
> 
> Looking through the documentation, and testing the built-in page-
> breaking algorithms, there doesn't seem to be a turn-key solution for my
> use-case. The default optimal-breaking algorithm starts every \score on
> the next page (even or odd), and page-turn-breaking forces every \score
> to start on an even page, which causes (almost) blank pages (the last
> line is put on the odd page) after all tunes which would happily fit on
> 1 page.
> 
> I tried fiddling with the different blank-page-*-penalties, but so far I
> wasn't able to achieve my goal. Is it possible after all?
> 
> 
> Best,
> Johannes



signature.asc
Description: This is a digitally signed message part.


Page turning in song book: Only \scores with more than 1 page should be forced to start on even page number

2022-02-23 Thread Johannes Maibaum
Hello,

I am working on a lead-sheet song book (i.e. one \book with many short
\scores inside), and I was looking for a way to optimize page turning
for musicians playing tunes from the book. Most songs fit on a single
page, but there are a few songs which span 2 or more pages.

I want to make sure that all songs which more than 1 page start on an
even page, but all 1-page songs should be allowed to start on an even or
an odd page.

Looking through the documentation, and testing the built-in page-
breaking algorithms, there doesn't seem to be a turn-key solution for my
use-case. The default optimal-breaking algorithm starts every \score on
the next page (even or odd), and page-turn-breaking forces every \score
to start on an even page, which causes (almost) blank pages (the last
line is put on the odd page) after all tunes which would happily fit on
1 page.

I tried fiddling with the different blank-page-*-penalties, but so far I
wasn't able to achieve my goal. Is it possible after all?


Best,
Johannes