| [frogs] Re: Patching the output file naming code (Was: thanks to whomever put this in the LSR...) |
[ Thread Index | Date Index | More lilynet.net/frogs Archives ]
|
Hi Reinhold, I've now started doing some work on this, and the big disadvantage with the current use of #(define output-suffix "whatever") et al. is that they affect all the files in all \score or \bookpart sections. What I would like to do is pick up a value of the property from something like a \paper block within the current \score or \bookpart. Is \paper the right place to put properties relating to output filenames, or should it be property of \score itself? Either \bookpart { \header { blah... } \score \with {output-suffix="Allegro"}{ blah... } } Or \bookpart { \header { blah... } \score { \paper { output-suffix= "Allegro} } blah... } } Now how do I pick up a property value from a specific currently active lilypond block in Scheme? I can pick up the results of #(define output-suffix "Allegro") by calling ly:parser-lookup. What do I use for lily property? Below is my latest attempt (define (get-outfile-name parser base ) (let* ((output-suffix (ly:parser-lookup parser 'output-suffix)) (counter-alist (ly:parser-lookup parser 'counter-alist)) (alist-key '()) (result '()) (output-count (assoc-ref counter-alist output-suffix)) ) (if (string? output-suffix) (set! alist-key (format "~a-~a" base (string-regexp-substitute "[^a-zA-Z0-9-]" "_" output-suffix))) (set! alist-key base)) (set! result alist-key) ;; must be careful: output-count is under user control.. (if (not (integer? output-count)) (set! output-count 0)) (if (> output-count 0) (set! result (format #f "~a-~a" alist-key output-count))) (ly:parser-define! parser 'counter-alist (assoc-set! counter-alist alist-key (1+ output-count))) result) ) (define (print-book-with parser book process-procedure) (let* ((paper (ly:parser-lookup parser '$defaultpaper)) (layout (ly:parser-lookup parser '$defaultlayout)) (base (ly:parser-output-name parser)) (outfile-name (get-outfile-name parser base)) ) (process-procedure book paper layout outfile-name) )) Cheers, Ian } Reinhold Kainhofer wrote: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Dienstag, 9. Juni 2009 23:29:34 schrieb Ian Hulin: |
| Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |