Hi Timothy,
Thanks so much for your answer! With $defaultheader I can indeed get the
main/global header fields in the initialize stage of the engraver, which
is already a very important step. I looked up where $defaultheader is
defined, and tried toplevel-scores and toplevel-bookparts as well as
$current-book and $current-bookpart but these sadly do not contain any
info (yet) when in the initialize step of the score context engraver.
Your solution for the score level headers is sadly unusable for me, as
the concept of the braille conversion as a simple include only addition
doesn't allow me to require users to create variables to get references
to these score blocks. It should work without any user-side change to
the Lilypond code the user delivers.
I tried to see what the difference is between what
(ly:translator-context engraver) returns and what the value is of your
\myscore variable, and see that the first is #<Context Score> where
\myscore is #<Score>. Is there any way that I would be able to get the
value #<Score> from somewhere inside that initialize step of the engraver?
That would allow me to use the (ly:score-header) function, and get
things that way.
Thanks again!
Maurits
Op 27-03-2024 om 18:07 schreef Timothy Lanfear:
On 26/03/2024 14:01, Maurits Lamers via LilyPond user discussion wrote:
- is there a way to get a listener or callback of some kind to
capture out-of-music markup?
- is there a way to get access to the global headers and / or score
headers (in case of score specific headers)?
- is there documentation on how to get a reference to the required
parameters for these scheme functions?
Here is an example for printing the global headers and score headers.
You can also print the global headers from the initialize translator
step of your engraver.
\version "2.24.0"
Header_export =
#(lambda (context)
(make-engraver
((initialize translator)
(ly:message "Print global headers with engraver\n")
(printheader $defaultheader))))
#(define (headerfield header field)
(if (and header (module-defined? header field))
(ly:message "header field: ~a — value: ~a \n" field (module-ref
header field))))
#(define (printheader header)
(headerfield header 'opus)
(headerfield header 'title)
(headerfield header 'piece))
\layout { \context { \Score \consists \Header_export } }
\header {
title = "Title"
opus = "Op 1"
}
myscore = \score { \header { piece = "Piece" } { c'1 } }
\myscore
#(printheader $defaultheader)
#(printheader (ly:score-header myscore))