lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: setting the number of pages for a score


From: Han-Wen Nienhuys
Subject: Re: setting the number of pages for a score
Date: Fri, 10 Feb 2006 01:55:03 +0100
User-agent: Mozilla Thunderbird 1.0.7-1.1.fc4 (X11/20050929)

[this seems out of scope for the user list]

Joe Neeman wrote:
I am writing a combined page/line breaker that aims to break pages in a page-turnable way. The idea is that the user will add \allowPageBreak in certain places, then lilypond will break the pages optimally with page turns only at those allowed places. The actual page-breaking part is currently a mess, but I think the line breaker is mostly OK, so I am enclosing a patch for my new line breaker.

Wow! See below for some comments.

The idea for the page breaker is that, using a similar algorithm to the current Gourlay line breaker, it will try out different numbers of systems on each page until it finds the solution with the least combined line and page demerits. The starting/ending point specification in the line breaker allows the page breaker to only line break the segment of music between 2 possible page breaks.

As I said previously, the page breaker is still a mess. It's mostly related to the fact that lilypond assumes that, once the line breaking is done, it can throw away unneeded grobs. Since I need to try many different line breakings, this is causing problems.

I don't understand; how do you use line breaking in the page-breaker? Within the current architecture, the vertical formatting step is non reversible, so you can't really figure out the height of one line-break configuration (which requires vertical formatting), and then try with another set of line-breaks.

Doing that would require some copy-on-write mechanism, so can you store the pre-line-break state of the formatting problem and run the line-breaking/formatting-step in on a copy. That's sort of hairy, although it should be doable: all state is maintained as Scheme alists. It's a matter of copying each grob, and doing a global pointer subsititution. Of course, there will be some details, and the copy-on-write would have to function across \score boundaries, since a page may have multiple \scores.

PS: this is probably a stupid question, but how do I get CVS to give me a diff including new files? I tried the -N option, but that didn't work. As a result, I attach a patch for my changes to existing files and my new files in full (I know this is discouraged, sorry).

It's OK, I don't know either.

   Let A_{k,n} = (a_{k,n,1}, ... a_{k,n,k}) be the optimal set of line breaks
   for k systems and n potential breakpoints. a_{k,n,k} = n (it is the end of
   the piece)

   Then A_{k+1, m} is contructed from
                        min_ {k <= j < m} ( W(A_{k,j} :: m) )
   where by A::m we denote appending m to the list A

OK, I think I get this, but I would expect j to run from k + 1, upwards as the number of breakpoints is always at least one more than the number of systems.

The code looks good, I'm actually surprised at how simple it is!

I expect that a full optimal page layout module is still far away, but we could roll out constrained line breaking relatively easily. For a lot of music, specifying a system count will make it easy to force a piece onto a number of pages, with a few well-placed \pageBreaks. Much easier than it is now anyway. What do you think?

/* start_idx and sys here are indexed from 0.
 * max_brk is indexed from start_brk_idx_[start_idx]
 * (for max_brk, start_brk_idx_[start_idx] is the beginning
 * of the piece; the smallest value we should ever see here is
 * start_brk_idx_[start_idx] + 1) */

--
 Han-Wen Nienhuys - address@hidden - http://www.xs4all.nl/~hanwen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]