3

I am writing a Scheme function to semi-automatically compile a few different books from a source file (with various sets of scores, instruments etc. included in each book). When handling a Book object, I can append a score to it quite simply:

(ly:book-add-score! book score)

However, I would also want to insert some page breaks between those scores. The obvious solution does not work:

(ly:book-add-score! book #{ \score { \pageBreak } #})

produces the output "warning: skipping zero-duration score", and of course no page break. I guess that I must append the page break, not as a score, but as markup (using a variant of the add-text function from scm/lily-library.scm maybe)? However, every attempt to do this resulted in an (opaque) Guile error.

1 Answer 1

4

Toplevel \pageBreak et al. calls are translated to special objects that are called "page markers". This is internally done using collect-music-aux, which takes as first argument the score handler (in your case this would be something like (lambda (score) (ly:book-add-score! book score))) and the music as second argument.

So you’d do something like

(collect-music-aux
 (lambda (score) (ly:book-add-score! book score))
 #{ \pageBreak #})

Of course you could also directly create the page marker you need and pass that to ly:book-add-score!.

Remark: This function handles toplevel music expressions, so if you do { c d e } this function is responsible for invoking scorify-music to wrap this into a score object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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