lilypond-devel
[Top][All Lists]
Advanced

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

Re: Creating books with Scheme


From: Nicolas Sceaux
Subject: Re: Creating books with Scheme
Date: Sat, 29 Aug 2009 18:09:48 +0200


Le 29 août 09 à 14:28, Reinhold Kainhofer a écrit :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am Montag, 17. August 2009 12:05:23 schrieb Nicolas Sceaux:
Le 17 août 09 à 09:23, Nicolas Sceaux a écrit :
If you look at the definition of `bookpart-score-handler' in my
file, you see that the book-part argument is not used. Instead,
all scores are added to the toplevel-scores parser variable (even
though they are not really toplevel, it does not matter).
The `toplevel-bookpart-handler' then uses this variable to actually
add the scores to the bookpart. This function is called by the parser when a \bookpart block is closed, so at this point the bookpart object
is known.

You can change the book-score-handler and toplevel-book-handler to
act the same way.

Here is a short example showing how that may be done.

Thanks a lot, but I just realized that if you use several bookparts, the \header section of the bookparts get ignored. Also, you cannot mix explicitly
written scores with computer-generated scores...

After playing for a while with handlers, it seems that properly mixing
programmaticaly-generated scores and explicit scores requires some tweaks in the parser. The hacks exposed earlier cannot deal with all various cases.

Proposition:

At the beginning of a \book (or \bookpart) block, the parser sets a
eg. $book (or $bookpart) parser variable, and unset it at the end of the
block.

Then, scores can be programmatically added this way:

(define (add-score parser score)
   (cond ((ly:parser-lookup parser '$bookpart)
(bookpart-score-handler (ly:parser-lookup parser '$bookpart) score))
         ((ly:parser-lookup parser '$book)
          (book-score-handler (ly:parser-lookup parser '$book) score))
         (else
          (toplevel-score-handler parser score))))

Nicolas





reply via email to

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