Hello Eef,
if I understand you correctly you essentially want to put the content of a
Lilypond file into a variable and evaluate that. This is not possible with
Lilypond as such, but instead you can avoid Lilypond syntax and directly use
the scheme hooks.
Instead of doing
all = ...
you can have a scheme function do
(set! all ...)
(but for this to work you need to have the binding "all" existing before by
doing #(define all #f) (or any other value).
Instead of simply creating a \score ... and let the parser delegate this to
the correct hook you can pass scores directly via scheme by doing
(add-score #{ \score { ... } #})
Generally there are many ways to do things, and we’d need to know more about
your specific situation to be able to elaborate a good solution.
Recently I did a mass for which I created a small framework which allows me to
first register parts and such by doing
\registerPart partname
\partSetTitle partname "Title"
\partSetStaff partname staffname { music }
...
and then when needed do
\partPrint name layoutfunction
to create a specific score or
\printParts layoutfunction
to print all scores.
layoutfunction is then a function taking partname and creating the desired
score.
I’d then have a folder "layouts" specifying layout functions, a folder
"styles" specifying stylesheets, and a folder of files registering scores, and
one or multiple masters reading these files and printing scores with one or
multiple layout functions.
I’ve included the core library and an example layout function. Maybe this
approach could be useful for you (I’ve also sent this to the list not too long
ago).
Cheers,
Valentin
Am Freitag, 7. April 2023, 16:11:43 CEST schrieb Eef Weenink:
I have this project: I make arrangements of figured bass pieces.
(Generalbass Wolf). In total 100 pieces. Uptill now I organised it this
way:
- 1 file with all pieces in it (I did about 10, 90 to go).
The file starts with an include of a startup.ily, with some settings for the
whole book then the first piece.
I include a file (arrangeit.ily) to change the music into several voices,
etcetera using arranger.ly<http://arranger.ly>. I add some lines to change
1-2 voices a bit using also arranger.ly<http://arranger.ly> then I include
a file (Generalbassmakescore.ily with the settings to create the score.
Second piece (with the same variablenames!)
and repeat the includes like mentioned above.
etcetera.
It works, looks well. At the end I have 1 file with alle the pieces and 3-4
files to do small jobs, It is not fast.
But somehow I have the idea this could be easier/better. But how?
- One idea would be to put all pieces in separate files and include this in
one file with all jobs: arranging, extra changes, create voice/score. But
then I will have 101 files
Most easy would be to create a file with procedures I need, include the file
and call the procedures when needed. . But how? Lilypond does not have
procedures (as far I know?). Using functions gives lots of errors.
I tried it with variables, but no luck either.
I try to put these lines in a variable/function/procedures (as an example):
What to do, to make lilypond use the lines between {} simply as a
replacement of the variable?
arrangeit = {
%----- verwerking-------
all = #'(pright pleft soprano alto tenor bass viola contrabas soprano)
#(init all)
#(begin
;;pianopartij
(rm 'pright '(1-4) (rel 1 'melody) )
(rm 'pleft '(1-4) (rel 'bassline) )
;; koorpartijen
;; sopraan
(rm 'soprano '(1-4) (note 1 (rel 'melody) ))
;;alt
(rm 'alto '(1-4) (note 2 (rel 1 'melody)) )
;; tenor
(rm 'tenor '(1-4) (note 3 (rel 1 'melody) ))
;; bass
(rm 'bass '(1-4) (rel 'bassline) )
;;ciontrabass
(rm 'contrabas ' (1-4) (rel 'bassline) )
)
}
Eef
<full-score.ily><partManager.ily>