ly:one-line-breaking
Hi all, Is there a way to make LilyPond also automatically adjust the paper height when using this? \paper { page-breaking = #ly:one-line-breaking } Thanks for the help! Regards, Mathieu ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
ly:one-line-breaking
I was wondering if it would be possible to develop a variant of "all on one line", namely "all on one page", where the page height would be automatically adjusted to fit the music, leaving the width as set. I could not see where the ly:one-line-breaking algorithm was written however (looking in the .scm and .ly files) is it in C++ ? Richard ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: ly:one-line-breaking
On 06.01.2016 18:18, Mathieu Demange wrote: Hi all, Is there a way to make LilyPond also automatically adjust the paper height when using this? \paper { page-breaking = #ly:one-line-breaking } I do not think there is a vertical analogon to this. Seems like you are condemned to trial & error… Best, Simon ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: ly:one-line-breaking
2016-01-06 19:31 GMT+01:00 Simon Albrecht : > On 06.01.2016 18:18, Mathieu Demange wrote: >> >> Hi all, >> >> Is there a way to make LilyPond also automatically adjust the paper height >> when using this? >> >> \paper { >> >>page-breaking = #ly:one-line-breaking >> >> } > > > I do not think there is a vertical analogon to this. Seems like you are > condemned to trial & error… > > Best, Simon You could try to invoke lilypond with the -dpreview option. And/or investigate how it is done with this option and adjust it to your needs, if possible at all. Cheers, Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: ly:one-line-breaking
> On Jan 9, 2016, at 1:30 PM, Richard Shann wrote: > > I could not see where the ly:one-line-breaking algorithm was written > however (looking in the .scm and .ly files) is it in C++ ? Yes, see: lily/page-breaking-scheme.cc lily/one-line-page-breaking.cc HTH, -Paul ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: ly:one-line-breaking
Am 9. Januar 2016 19:30:56 MEZ, schrieb Richard Shann : >I was wondering if it would be possible to develop a variant of "all on >one line", namely "all on one page", where the page height would be >automatically adjusted to fit the music, leaving the width as set. I had been thinking about "abusing" lilypond-book-preamble for this and "stitching" the systems together. HTH Urs >I could not see where the ly:one-line-breaking algorithm was written >however (looking in the .scm and .ly files) is it in C++ ? > >Richard > > > >___ >lilypond-user mailing list >lilypond-user@gnu.org >https://lists.gnu.org/mailman/listinfo/lilypond-user -- Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: ly:one-line-breaking
On Sat, 2016-01-09 at 13:38 -0500, Paul Morris wrote: > > On Jan 9, 2016, at 1:30 PM, Richard Shann wrote: > > > > I could not see where the ly:one-line-breaking algorithm was written > > however (looking in the .scm and .ly files) is it in C++ ? > > Yes, see: > > lily/page-breaking-scheme.cc > lily/one-line-page-breaking.cc oh, yes, thanks, I see. That code does look so well-written, but I guess it would take quite a bit of study of the underlying concepts to understand how to tweak it. Richard ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: ly:one-line-breaking
On Sat, 2016-01-09 at 21:18 +0100, Urs Liska wrote: > > Am 9. Januar 2016 19:30:56 MEZ, schrieb Richard Shann > : > >I was wondering if it would be possible to develop a variant of "all on > >one line", namely "all on one page", where the page height would be > >automatically adjusted to fit the music, leaving the width as set. > > I had been thinking about "abusing" lilypond-book-preamble for this and > "stitching" the systems together. Hmm, not at all sure what's going on in that file, it would be nice if there were some simple tweak that pulled it off though... Richard ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: ly:one-line-breaking
> On Jan 9, 2016, at 1:30 PM, Richard Shann wrote: > > I was wondering if it would be possible to develop a variant of "all on > one line", namely "all on one page", where the page height would be > automatically adjusted to fit the music, leaving the width as set. Well, I made a couple of partially successful attempts. See two patches attached. I basically followed the examples of minimum line breaking and one line breaking, while trying to understand page-breaking.cc. The challenge is calculating the exact page height needed to fit the music. INITIAL ATTEMPT Here I access the vertical extent of each system and add them together, along with top and bottom margins, to calculate the page height that would allow all systems fit on one page. But this doesn't take into account the spacing between systems so the page height is underestimated. So next I access system-system-spacing.basic-distance, and add that in. But system-system-spacing is measured from the center of the staff (see [1]), so the page height is overestimated. There doesn’t seem to be any way to use these spacing settings to calculate the height. (I should have seen this coming…) [1] http://lilypond.1069038.n5.nabble.com/attachment/164161/0/vertical-spacing-paper-variables.pdf Maybe (presumably?) somewhere in the vertical spacing code there is a reliable way to get an exact height value based on an actual layout of music on the page (without any compression), but I haven’t found it. (Also top level markups, titles, etc. cause a crash with this code…) ANOTHER ATTEMPT Here the idea was to simply take the default layout on N pages and then calculate a page height that would be equal to the total of all of the heights of those N pages – effectively merging the N pages into one page. For some reason the resulting paper height often seems to be short (despite using an existing routine to get the default paper height), and I’m not sure what’s going wrong. LilyPond does seem to fit all the systems onto one page in those cases, but with some compression, and ideally there shouldn’t be any need for compression. (Top level markups, titles, etc. work fine, but there are some programming errors reported in the log about trying to fit music... crossing fingers… etc. but the results seem to come out ok.) (I also tried some code that progressively increased or decreased the page height, attempting new page breaking at each size, to locate the threshold between one and two pages, which would be the height needed. But this didn’t work. No matter the page height the number of pages stayed the same, I suspect because of caching of values for a given page breaking configuration.) There's a staggeringly sophisticated system for fitting music onto pages that have a constant size, but keeping the music constant and changing the page size to fit it is another story. Anyway, it's a start. I’m putting this on the shelf for now, but wanted to share what I’d done to prevent duplication of effort if anyone else feels inclined to take this on. (I’m mostly interested in how this would allow for creating SVG images where the size of the image is automatically cropped to fit the music (with user customizable margins) rather than having to do this manually with Inkscape.) -Paul %%% TEST SNIPPET %%% \version "2.19.36" \paper { % system-system-spacing.basic-distance = #0 page-breaking = #ly:one-page-breaking % ragged-bottom = ##t % top-margin = 0 % bottom-margin = 0 % system-system-spacing.minimum-distance = #0 % system-system-spacing.padding = #0 } \header { % title = "a title" tagline = "" } % \markup \large "top level markup" \repeat unfold 200 { c' d' e' f' } % 0001-initial-attempt-at-one-page-breaking.patch Description: Binary data 0001-initial-attempt-at-one-page-breaking.patch Description: Binary data ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
ly:one-page-breaking (was: ly:one-line-breaking)
> On Jan 9, 2016, at 1:30 PM, Richard Shann wrote: > > I was wondering if it would be possible to develop a variant of "all on > one line", namely "all on one page", where the page height would be > automatically adjusted to fit the music, leaving the width as set. I’m glad to report that I’ve made some real progress. The code in the attached patch delivers the basic functionality, with a few "known issues". Namely the tagline and any footnotes are not included, and bookparts trigger default page breaking for some reason. I haven’t tested it extensively but titles (etc.), top level markups, multiple scores, all seem to work just fine. The approach is to temporarily set the page-height to the largest size possible, do the line breaking and page layout for that page height, then get the vertical position on the page and the height of the lowest system (or top level markup), and use that to calculate and then set the final page height so that it fits the content of the page. (Also, I now see how to improve the ly:one-line-auto-height code to avoid some of the unintuitive results related to bottom-margin and top-system-spacing. So a new patch set for that is on the way, when I can get to it...) -Paul %%% TEST SNIPPET %%% \version "2.19.36" \paper { % system-system-spacing.basic-distance = #0 page-breaking = #ly:one-page-breaking % ragged-bottom = ##t % top-margin = 0 % bottom-margin = 0 % system-system-spacing.minimum-distance = #0 % system-system-spacing.padding = #0 } \header { % title = "a title” % tagline = "" } % \markup \large "top level markup" \repeat unfold 100 { c’4 d' e' f’ } \repeat unfold 10 { g'1 } { c,1 } % \markup \large “another top level markup" % one-page-breaking-1-18-2016.patch Description: Binary data ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
ly:one-page-breaking (was: ly:one-line-breaking)
> On Jan 9, 2016, at 1:30 PM, Richard Shann wrote: > > I was wondering if it would be possible to develop a variant of "all on > one line", namely "all on one page", where the page height would be > automatically adjusted to fit the music, leaving the width as set. I’m glad to report that I’ve made some real progress. The code in the attached patch delivers the basic functionality, with a few "known issues". Namely the tagline and any footnotes are not included, and bookparts trigger default page breaking for some reason. I haven’t tested it extensively but titles (etc.), top level markups, multiple scores, all seem to work just fine. The approach is to temporarily set the page-height to the largest size possible, do the line breaking and page layout for that page height, then get the vertical position on the page and the height of the lowest system (or top level markup), and use that to calculate and then set the final page height so that it fits the content of the page. -Paul %%% TEST SNIPPET %%% \version "2.19.36" \paper { % system-system-spacing.basic-distance = #0 page-breaking = #ly:one-page-breaking % ragged-bottom = ##t % top-margin = 0 % bottom-margin = 0 % system-system-spacing.minimum-distance = #0 % system-system-spacing.padding = #0 } \header { % title = "a title” % tagline = "" } % \markup \large "top level markup" \repeat unfold 100 { c’4 d' e' f’ } \repeat unfold 10 { g'1 } { c,1 } % \markup \large “another top level markup" % one-page-breaking-1-18-2016.patch Description: Binary data ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: ly:one-page-breaking (was: ly:one-line-breaking)
> On Jan 18, 2016, at 7:09 PM, Paul Morris wrote: > > (Also, I now see how to improve the ly:one-line-auto-height code to avoid > some of the unintuitive results related to bottom-margin and > top-system-spacing. So a new patch set for that is on the way, when I can > get to it...) Actually I tried this and it didn’t work as I’d hoped… Sorry for the duplicate messages. I had some email issues today. -Paul ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: ly:one-page-breaking (was: ly:one-line-breaking)
On Mon, 2016-01-18 at 22:51 -0500, Paul Morris wrote: > > On Jan 9, 2016, at 1:30 PM, Richard Shann wrote: > > > > I was wondering if it would be possible to develop a variant of "all on > > one line", namely "all on one page", where the page height would be > > automatically adjusted to fit the music, leaving the width as set. > > I’m glad to report that I’ve made some real progress. > The code in the attached patch delivers the basic functionality, with a few > "known issues". > Namely the tagline and any footnotes are not included, > and bookparts trigger default page breaking for some reason. > I haven’t tested it extensively but titles (etc.), top level markups, > multiple scores, > all seem to work just fine. That's great news! For the application to Denemo taglines and footnotes are not wanted anyway as it is for creating a score to play from on-screen. I guess it will be some time before this code gets into a release? > The approach is to temporarily set the page-height to the largest size > possible, What is the largest size possible? I tried playing around with some sizes, and some didn't work ... > do the line breaking and page layout for that page height, then get the > vertical position on the page and the height of the lowest system (or top > level markup), and use that to calculate and then set the final page height > so that it fits the content of the page. A crude version of this is what will be in the impending Denemo release - Denemo creates the SVG output and counts the pages and then re-runs LilyPond at a larger page size. Richard ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: ly:one-page-breaking (was: ly:one-line-breaking)
> On Jan 19, 2016, at 4:02 AM, Richard Shann wrote: > > That's great news! For the application to Denemo taglines and footnotes > are not wanted anyway as it is for creating a score to play from > on-screen. > I guess it will be some time before this code gets into a release? It depends on whether or not this is acceptable with the current known issues. (Some other pressing demands mean that I need to take a break from LilyPond work for some months, so I won’t have time to further improve upon this any time soon.) In its current state it would already work for many of the more obvious use cases – like Denemo’s on-screen score or producing image files destined for other documents. Should I put this up for code review or should we discuss this on the dev list? …or in an issue tracker? >> The approach is to temporarily set the page-height to the largest size >> possible, > > What is the largest size possible? I tried playing around with some > sizes, and some didn't work … I tried setting it to positive infinity, but that gave a programming error when there was a tagline. I traced the error to Stencil::translate, which throws the error for any value greater than 1e6. So I used 1e6 as the temporary page-height and everything is working fine. >> do the line breaking and page layout for that page height, then get the >> vertical position on the page and the height of the lowest system (or top >> level markup), and use that to calculate and then set the final page height >> so that it fits the content of the page. > > A crude version of this is what will be in the impending Denemo release > - Denemo creates the SVG output and counts the pages and then re-runs > LilyPond at a larger page size. I think that should work pretty well for your use case. I considered a similar approach before I worked out the current one. -Paul ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user