OK,
I've been able to do a bit more digging around since I got home and
found David's fix for Issue 2343 and related Rietveld
https://codereview.appspot.com/5698050/
Most of the patch was a nice new procedure paper-variable in
scm/lily-library.scm for getting and setting variables within a \paper
block, looking in any relevant \book (and by implication \bookpart or
top-level declaration.
========================================
(define-public paper-variable
(let
((get-papers
(lambda (parser book)
(append (if (and book (ly:output-def? (ly:book-paper book)))
(list (ly:book-paper book))
'())
(ly:parser-lookup parser '$papers)
(list (ly:parser-lookup parser '$defaultpaper))))))
(make-procedure-with-setter
(lambda (parser book symbol)
(any (lambda (p) (ly:output-def-lookup p symbol #f))
(get-papers parser book)))
(lambda (parser book symbol value)
(ly:output-def-set-variable!
(car (get-papers parser book))
symbol value)))))
===========================================
Most of the rest of the patch was concerned with moving lookups from
parser global variables to using the paper-variable procedure to look
things up in the \paper block.
My question is: can we get away with an equivalent midi-variable
procedure, or do we need this *and* to extend the book object in C++
to add a midi_ property, all the attendant methods as per the paper_
methods, and also an ly:book-midi scheme-callable procedure, so
midi-variable would look something like
(define-public midi-variable
(let
((get-midis
(lambda (parser book)
(append (if (and book (ly:output-def? (ly:book-midi book)))
(list (ly:book-midi book))
'())
(ly:parser-lookup parser '$midis)
(list (ly:parser-lookup parser '$defaultmidi))))))
(make-procedure-with-setter
(lambda (parser book symbol)
(any (lambda (p) (ly:output-def-lookup p symbol #f))
(get-midis parser book)))
(lambda (parser book symbol value)
(ly:output-def-set-variable!
(car (get-midis parser book))
symbol value)))))
This would require changes in lily/book.cc and lily/book-scheme.cc.
What do you think? Or is there a simpler solution?
I think this is where I backed off from implementing the block
variables before and added the \bookOutputName and \bookOuputSuffix
commands instead.
Cheers,
Ian
On 26/12/12 15:53, Ian Hulin wrote:
> First of all, a very Merry Christmas to you all.
>
> Unfortunately I've had to spend the holidays in hospital, but I'm
> now a much happier bunny now I have my notebook and have sorted out
> a mobile broadband link.
>
> I'm trying to prototype something so we can specify names and/or
> suffixes for midi files and would like to see if I can add
> property checks for things in the \midi block like
>
> \midi { filename = "Coronation-Anthem" file-suffix =
> "Zadok-the-Priest"} }
>
> I know ly:output-def-lookup is my friend, but how do I get hold of
> the currently active midi block so I can look up the property?
>
> Sorry if this seems an obvious question, and I'd probably get the
> answer if I was at home, but I'm out on a limb a bit here.
>
> Thanks in advance for your help,
>
> Cheers, Ian Hulin
>
_______________________________________________
lilypond-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-devel