-----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...

Attached is a modified sample file:
- -) if you have explicitly written \score{..}s and computer-created ones, the 
explicitly written ones will start a new book part, even if all are inside the 
same \bookpart.
- -) Only the first bookpart uses the global \header for piece names
- -) The scheme-generated scores in the second and further bookparts will 
ignore 
all header settings! 
- -) The explicitly written scores in the second bookpart will also ignore all 
global header settings?!?

Do you have any idea, how I can (i) assign the correct header blocks to the 
generated scores (ie. proper hierarchy: score-level header, bookpart-level 
header, book-level header and finally global header block in this order) and 
(ii) how I can treat generated and explicitly written scores really equal.

Thanks a lot,
Reinhold

PS: It works correctly, if I use different \book blocks instead of \bookpart 
blocks, but that's not what I want.
- -- 
- ------------------------------------------------------------------
Reinhold Kainhofer, reinh...@kainhofer.com, http://reinhold.kainhofer.com/
 * Financial & Actuarial Math., Vienna Univ. of Technology, Austria
 * http://www.fam.tuwien.ac.at/, DVR: 0005886
 * LilyPond, Music typesetting, http://www.lilypond.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iD8DBQFKmR8DTqjEwhXvPN0RAoeIAJ9MLa5q7ZDVyDHr5fdOloZYnLmYkQCdGit/
MTy2oK8nz89pwbUlGgZXqoc=
=CyVk
-----END PGP SIGNATURE-----
\version "2.13.4"

#(define-public (add-score parser score)
   (ly:parser-define! parser 'toplevel-scores
                      (cons score (ly:parser-lookup parser 'toplevel-scores))))

#(define-public (add-text parser text)
  (add-score parser (list text)))

#(define-public (add-music parser music)
  (collect-music-aux (lambda (score)
		       (add-score parser score))
                     parser
		     music))

#(define-public (toplevel-book-handler parser book)
   (map (lambda (score)
          (ly:book-add-score! book score))
        (reverse! (ly:parser-lookup parser 'toplevel-scores)))
   (ly:parser-define! parser 'toplevel-scores (list))
   (print-book-with-defaults parser book))

#(define-public (book-score-handler book score)
   (add-score parser score))

#(define-public (book-text-handler book text)
   (add-text parser text))

#(define-public (book-music-handler parser book music)
   (add-music parser music))

%%%

#(define add-one-note-score #f)
#(let ((pitch 0))
  (set! add-one-note-score
        (lambda (parser)
          (let* ((music (make-music 'EventChord
                          'elements (list (make-music 'NoteEvent
                                            'duration (ly:make-duration 2 0 1 1)
                                            'pitch (ly:make-pitch 0 pitch 0)))))
                 (score (scorify-music music parser))
                 (layout (ly:output-def-clone $defaultlayout))
                 (note-name (case pitch
                              ((0) "do")
                              ((1) "ré")
                              ((2) "mi")
                              ((3) "fa")
                              ((4) "sol")
                              ((5) "la")
                              ((6) "si")
                              (else "huh")))
                 (title (markup #:large #:line ("Score with a" note-name))))
            (ly:score-add-output-def! score layout)
            (add-text parser title)
            (add-score parser score))
            (set! pitch (modulo (1+ pitch) 7)))))

oneNoteScore =
#(define-music-function (parser location) ()
   (add-one-note-score parser)
   (make-music 'Music 'void #t))

%%%

\header {
  title = "Main Title"
  subtitle = "Main subtitle"
  piece = "Piecetitle"
}

\oneNoteScore

\bookpart {
  \header { title ="Title 1" subtitle="Sub1"}
  \oneNoteScore
  \oneNoteScore
  \oneNoteScore
  \score { \relative c' c1 }
}


\bookpart {
  \score { \relative c' c1 }
  \oneNoteScore
  \oneNoteScore
  \oneNoteScore
}


\bookpart {
  \score { \relative c' c1 }
  \oneNoteScore
  \oneNoteScore
  \oneNoteScore
  \header { title ="Title 3" subtitle="Sub3" piece="Pieces 3.x"}
}

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to