lilypond-user
[Top][All Lists]
Advanced

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

Re: Doing \score { <<...>... } and \context Staff << .... >> in scheme?


From: Nicolas Sceaux
Subject: Re: Doing \score { <<...>... } and \context Staff << .... >> in scheme?
Date: Wed, 20 Feb 2008 20:15:07 +0100

Le 19 févr. 08 à 14:53, Reinhold Kainhofer a écrit :

Thanks for adding these bindings. However, should ly:score-header always return a header module, or do I have to create the header module myself? For me it simply returns an empty list... In particular, the following code does
not work:

#(define (createscoreII name)
 (let* (
        (score (ly:make-score #{ \makestaff $name #}))
        ; I also tried (make-module 1021 (ly:score-header score)
        ; where 1021 is taken from the only call to make-module that I
        ; found in scm/lily.scm
        (header-object (ly:score-header score))
        ;(header-object (make-module 1021 (ly:score-header score)))
       )
   ;(display header-object)
   ; This complains about header-object not being a module.
; using make-module, it complains about now knowing the piece variable...
   (module-set! header-object 'piece "blah")
   (ly:export score)
 )
)

I also tried module-add!, but since I'm basically doing trial and error, I
could not get this to work, either...


module-define! is the function you were looking for.

Here is function that builds a score with a piece title and some music,
using the new bindings:

makeScore =
#(define-music-function (parser location title music) (string? ly:music?)
   (let ((score (ly:make-score music))
         (header (make-module)))
     (module-define! header 'piece title)
     (ly:score-set-header! score header)
     (collect-scores-for-book parser score))
   (make-music 'Music 'void #t))

\makeScore "Test" { c'4 d' e' f' g'1 }

nicolas





reply via email to

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