Hello, I'm working on a multi-movement piece, so far using a separate file for the score of each movement. I'm trying to add a file to the project that compiles all the movements and frontmatter into a single pdf, using bookparts, and I'm having trouble figuring out the best way to do that. The nicest way would be if all I needed to do were:
\book { \bookpart { \include "movement1_score.ly" } \bookpart { \include "movement2_score.ly" } } As you might guess, that fails because each of the included files itself includes a file (e.g. movement1_music.ly) containing variable declarations, and variable declarations aren't allowed inside bookparts. The solution to that problem is for me to include movement1_music.ly etc. outside the \book block. That causes another problem, though, because I am using the same variable naming scheme for each of the movements. Obviously, I could solve that problem by adding a prefix to all the variable names, but that seems really yucky to me. I find myself craving some way to reference same-named variables in different namespaces, like movement1.flute versus movement2.flute. Related to that craving is the fact that the score blocks for each of the movements are identical, which makes me feel like there ought to be some way to get rid of that code duplication. Really, I want to define the structure of the score block once, and then instantiate it multiple times, feeding each instance a different namespace, so that the first score block instance looks up "flute" in the movement1 namespace, while the second score block instance looks up "flute" in the movement2 namespace. I'm sure this can't be a unique use case. Any suggestions on the best way to accomplish some or all of this? Am I thinking too much like a Python programmer to see the natural way to approach these issues in Lilypond/Scheme? Are some of these issues unsolvable without changes to Lilypond? Some similar questions: http://lilypond.1069038.n5.nabble.com/Books-bookparts-includes-what-td52157.html http://lilypond.1069038.n5.nabble.com/bookparts-with-paper-blocks-td145242.html http://stackoverflow.com/questions/20858042/define-function-inside-score-in-lilypond Thanks, Saul -- View this message in context: http://lilypond.1069038.n5.nabble.com/cleanly-dealing-with-variables-and-reducing-code-duplication-in-multimovement-works-tp161112.html Sent from the User mailing list archive at Nabble.com. _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user