On 02/02/2015 02:34 PM, John McWilliam wrote: > I am compiling a collection of bagpipe tunes and am having a problem > when the individual files are to be compiled into a book. Many of the > tunes have sections of music defined in variables - these definitions > lie outside the \score context and are causing errors when I try to > compile the book. > > I have also noticed that my list of \include files also defined > outside the score context have to be removed form the individual > tunes and listed at the beginning of the book file instead. This is > not a problem since the list is short, however, moving all my music > variables to the book file seems like a clumsy way of doing things > since they are many and vary from tune to tune. > > Does anyone have a solution to this problem which could perhaps be > described as one of SCOPE or CONTEXT?
Unfortunately, this is one of the cases where LilyPond use resembles other kinds of computer programming. You’ll need to refactor your files... I’ve made a few books of songs or tunes. The music for each tune (or song) goes in its own file; there is a sibling wrapper for each tune that produces discrete output, which \includes the core music file. Then the book file \includes the music for all the tunes. A short example: =-=-=-= atholl_highlanders_tune.ly =-=-=-= \version "2.16.2" athollLayout = { ... } athollFullChords = { ... } athollFullTune = { ... } =-=-=-= end =-=-=-= =-=-=-= atholl_highlanders.ly =-=-=-= \version "2.16.2" \include "atholl_highlanders_tune.ly" theFullChords = \athollFullChords theFullTune = \athollFullTune theLayout = \athollLayout theTempo = #(ly:make-moment 420 8) theTitle = "The Atholl Highlanders" % tunes.ly actually handles the layout and MIDI % generation, given these variables \include "tunes.ly" =-=-=-= end =-=-=-= =-=-=-= crism_tunes.ly =-=-=-= \version "2.16.2" \include "atholl_highlanders_tune.ly" % ... \book { % ... \bookpart { \header { title = "Jigs" } \score { \athollLayout \header { title = "The Atholl Highlanders" } } \layout {} } % ... } % ... } =-=-=-= end =-=-=-= Now, I end up actually generating the wrapper files and the book .ly from an XML file, so that I can easily handle redundant information (indexes by alternate titles and key, e.g.), but that’s for a different time. To see the full files for a single tune, see <URL: http://music.maden.org/index.php?title=The_Atholl_Highlanders >; for a tune book sample, see <URL: http://crism.maden.org/music/crism_tunes.xml >, <URL: http://crism.maden.org/music/crism_tunes.ly >, and <URL: http://crism.maden.org/music/crism_tunes.pdf >. ~Chris -- Chris Maden, text nerd <URL: http://crism.maden.org/ > Surround hate and force it to surrender. GnuPG fingerprint: DB08 CF6C 2583 7F55 3BE9 A210 4A51 DBAC 5C5C 3D5E _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user