3

Sometimes lilypond tries to use less pages for more music, which is not always wanted. This can be easily fixed by manually adding \pageBreak , but sometimes an automatic solution is needed.

When vertical compression happens, lilypond log shows something like this:

warning: compressing over-full page by 36.9 staff-spaces
warning: page 4 has been compressed

In my particular situation lilypond script is generated by MusicXML analysis program and no manual tweaking of positions or pagebreaks is possible, because we do not know what music user can upload.

How can compression be totally disabled or limited, so that Lilypond would have to add page breaks? Automatic solution is required, which does not include manually tweaking positions of elements and pagebreaks.

Sorry for posting such a big example, but many elements are needed so that page is not enough any more. Here is an example of automatically generated score:

1. Automatic line breaking leads to vertically over-compressing first page (text lines are too close to each other, numbers inside score collide with text spanners):

https://github.com/rualark/MGen/blob/master/MGen/configs/ly2/debug/compressing/compressed2.ly

https://github.com/rualark/MGen/blob/master/MGen/configs/ly2/debug/compressing/compressed2.pdf

Mirror: http://lilybin.com/f7wjax/1

Mirror: https://www.hacklily.org/?edit=rualark/sheet-music/overcompressed.ly

2. Adding just one \pageBreak command fixes everything:

https://github.com/rualark/MGen/blob/master/MGen/configs/ly2/debug/compressing/uncompressed2.ly

https://github.com/rualark/MGen/blob/master/MGen/configs/ly2/debug/compressing/uncompressed2.pdf

Mirror: http://lilybin.com/7xlar8/1

Mirror: https://www.hacklily.org/?edit=rualark/sheet-music/uncompressed.ly

I already did a google search of known issues and visited lilypond documentation with no significant progress so far:

http://lilypond.org/doc/v2.18/Documentation/notation/vertical-spacing http://lilypond.1069038.n5.nabble.com/warning-compressing-over-full-page-by-12-4-staff-spaces-td168716.html

Please help!

  • 2
    "HackLily"? Can you find some less scary way to post your examples? – Todd Wilcox Feb 7 at 21:50
  • 1
    @ToddWilcox do you refer to the name or also to the functionality of this platform? It is similar to LilyBin. – Jasper Habicht Feb 8 at 6:28
  • 1
    In your example, you often use \once \override with the same properties. Why don’t you just use \override only once in the beginning? If you can navigate through your code, it’s fine, but it can be simplified a lot! And this would help others to understand it. Now, to your question: did you look into vertical positioning in the doc: lilypond.org/doc/v2.18/Documentation/notation/… – Jasper Habicht Feb 8 at 6:39
  • @ToddWilcox thanks, I added links to lilybin – Rualark Feb 8 at 7:16
  • @JasperHabicht sorry that I did not state clearly enough, that automatic solution is needed in this particular case. The script is generated completely by a program and human cannot interfere to add manual positions or page breaks (I updated the post). As for '\once', I use it to prevent overriding properties back to previous color, which both makes lilypond script longer and makes analysis program more difficult. If you consider this an important issue, I will try to think of a better solution. – Rualark Feb 8 at 7:20
1

As far as I know, you can only tell Lilypond how to space lines within one markup, but not between markups (except perhaps with a padding). This is especially problematic if this markup is not embedded into a Staff context. Maybe I am wrong, though …

So, you should probably not use many single \markup macros, but instead make use of a \markuplist and \wordwrap-lines. This should prevent Lilypond from compressing the spacing between single markup commands. At least, it is worth a try.

You can use one markuplist per paragraph, for example. The spec says, markuplists can span over several pages, so maybe you can even just use one. I don’t know how your script exactly works that generates this output, but maybe this is a feasible solution?

I added snippets from your code and in the following example but reduced it to the most important parts:

\version "2.18.2"
\language "english"
\paper { 
  #(include-special-characters) 
  bottom-margin = 0.27\in
}
% Your definitions here
\markup \wordwrap {
  \bold { "#"2 (from test-vocal-range) Key: G mixolydian }
  \tiny { "Lyrics:" "sp1." }
}
<<
% Your notes and formatting here
\new Staff = "staff1" {
  \set Staff.instrumentName = \markup { \teeny \override #'(baseline-skip . 2.0) \center-column{ "Part"  ""  "[Soprano]" } }
  \new Voice { \override NoteHead.color=#(rgb-color 1.000 0.000 0.000)
  d'1
  }
}
% etc.
>>
\markuplist {
  \wordwrap-lines { \tiny \bold "Part [bar 1, beat 1] note D" }
  \wordwrap-lines { \smaller \with-color #(rgb-color 1.000 0.000 0.000) "1 - Melody: Stagnation (5 notes <m3)" }
  \wordwrap-lines { \smaller \with-color #(rgb-color 1.000 0.000 0.000) "1 - Melody: Stagnation (5 notes <m3)" }
}
\markuplist {
  \wordwrap-lines { \tiny \bold "Part [bar 1, beat 1] note D" }
  \wordwrap-lines { \smaller \with-color #(rgb-color 1.000 0.000 0.000) "1 - Melody: Stagnation (5 notes <m3)" }
  \wordwrap-lines { \smaller \with-color #(rgb-color 1.000 0.000 0.000) "1 - Melody: Stagnation (5 notes <m3)" }
}
% ... and so on
  • Thanks for an idea! Yet, isn't it strange that we cannot prevent over-compressing blocks? For example, lilypond shows how many staff-spaces were compressed in the log above. Probably this value can be limited, but I cannot find how. – Rualark Feb 8 at 11:37
  • I tried this solution, but \markuplist \workwrap-lines entries have too far interval between them when uncompressed (see page 2). I tried to \override #'(baseline-skip . 2) with no success. The main problem with this approach is that markup inside score still collides with text spanners due to compression: github.com/rualark/MGen/blob/master/MGen/configs/ly2/debug/… github.com/rualark/MGen/blob/master/MGen/configs/ly2/debug/… – Rualark Feb 8 at 14:24
  • You are right. I found another possible approach: You could add #(define page-breaking ly:page-turn-breaking) to the \paper macro. This allows Lilypond to switch to another page-breaking algorithm. Perhaps this helps in some cases. The compression problem is still not really solved. As for the distances: try to add \override #'(baseline-skip . 2) in front of every \wordwrap-lines command. And the distances inside the score can probably be adjusted using paddings? – Jasper Habicht Feb 8 at 16:04
  • I found that adding #(define page-breaking ly:page-turn-breaking) to \paper macro solves problem completely. I read about this option before, but did not even try that, because this was not straightforward. Obviously, there are bugs in optimal-breaking and minimal-breaking which both give bad results for this test score. Unfortunately, page-turn-breaking tends to generate more pages, because it leaves more blank space - and sometimes a lot of unneeded blank space like on page 1 in this example: – Rualark Feb 8 at 20:50
  • Example of too much blank space on page 1: github.com/rualark/MGen/blob/master/MGen/configs/ly2/debug/… github.com/rualark/MGen/blob/master/MGen/configs/ly2/debug/… Looks much better with optimal-breaking: github.com/rualark/MGen/blob/master/MGen/configs/ly2/debug/… This is very unfortunate, because one method over-compresses and another is extremely sparse – Rualark Feb 8 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.