lilypond-user
[Top][All Lists]
Advanced

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

Re: Create a \bookpart in a Scheme function


From: Thomas Morley
Subject: Re: Create a \bookpart in a Scheme function
Date: Tue, 26 Jul 2016 20:58:40 +0200

2016-07-26 20:03 GMT+02:00 Urs Liska <address@hidden>:
> Hi all,
>
> one more of my recent confusing ideas: I would like to generate a number of
> \bookpart-s in a Scheme function. The reason is that I have to loop over a
> number of works and create scores for them that are in a bookpart each.
>
> Attached is something that resembles the structure I have in my actual
> files.
>
> I successfully factored out the bookpart to an includable file. With this I
> can produce multiple scores. However, it would be better to have that
> factored out to a function because I have to set some values to select which
> score to create, and this would be more natural to do as function arguments
> rather than setting global variables and reading that from the code that
> generates the scores.
>
> As the files are they compile finely, but when I uncomment the \makeBookpart
> call I get
>
> /home/uliska/Aktuell/lily/bookpart-in-scheme-function/main.ly:23:9: error:
> bad expression type
>
> \makeBookpart
>
> /home/uliska/Aktuell/lily/bookpart-in-scheme-function/main.ly:14:2: error:
> error in #{ ... #}
>
> # (let* errors. Any suggestions how I can make the outer construct handle a
> bookpart returned from a function? Thanks Urs


Not sure I understood what your aiming, but maybe:

\version "2.19.45"
makeBookpart =
#(define-void-function (book)(ly:book?)
  (ly:book-add-bookpart!
    book
    #{ \bookpart { \score { \new Staff { d' } } } #}))

#(let* ((book
         #{
           \book {
             \bookpart { \markup "This will be a title page" }
             \include "bookpart.ily"
             \include "bookpart.ily"
           }
         #}))
  #{ \makeBookpart #book #}
  (ly:book-process
    book
    #{ \paper {} #}  ; non-functional, placeholder
    #{ \layout {} #} ; non-functional, placeholder
    (ly:parser-output-name)))

HTH,
  Harm



reply via email to

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