Compilation error on music overflow: Difference between revisions
Appearance
Import snippet from LSR |
m New category |
||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
When you have multiple overflowing measures, the music flows off the page. This snippet forces an error when this happens by checking the width of each system and checking it against the paper width. | When you have multiple overflowing measures, the music flows off the page. This snippet forces an error when this happens by checking the width of each system and checking it against the paper width. | ||
<lilypond version="2.24 | <lilypond version="2.24"> | ||
scorepaper = \paper { } | scorepaper = \paper { } | ||
| Line 24: | Line 24: | ||
[[Category:Scheme]] | [[Category:Scheme]] | ||
[[Category:Paper and layout]] | [[Category:Paper and layout]] | ||
[[Category:Snippet]] | |||
Latest revision as of 23:32, 21 November 2025
When you have multiple overflowing measures, the music flows off the page. This snippet forces an error when this happens by checking the width of each system and checking it against the paper width.
\version "2.24"
scorepaper = \paper { }
#(define staffcount 0)
\relative c' {
\override Staff.StaffSymbol.after-line-breaking =
#(lambda (grob)
(set! staffcount (+ staffcount 1))
(let* ((staff-width (interval-length (ly:grob-property grob 'X-extent)))
(staff-space (ly:output-def-lookup scorepaper 'staff-space))
(paper-width (ly:output-def-lookup scorepaper 'paper-width))
(my-width (/ paper-width staff-space)))
(if (> staff-width my-width)
(ly:error "Music overflows page at staff ~a." staffcount))))
%% uncomment this and compilation will fail, throwing a music overflow error.
%r4
\repeat unfold 100 { c1 }
}