lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Compile twice with different includes


From: Urs Liska
Subject: Re: Compile twice with different includes
Date: Fri, 15 Feb 2013 11:40:12 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130106 Thunderbird/17.0.2

After a few test I have one further question.

I managed to tweak your functions to my needs (i.e. make it _less_ generic, because I need it for a specific purpose).

Attached you'll find my version of the function with example.
I created a function that only takes the \book as its argument, then processes it twice, assigning different first pages each.
While this actually does what I want I would like to make the input structure still more simple by passing the \score instead of the \book to the function.

What I'm actually doing is:
mybook = \book {
  \include "file-containing-score-block.ily"
}

\writeBookOddEven #mybook
which is somewhat redundant.

What I would like to write is:
\writeBookOddEven \include "file-containing-score-block.ily"

(or - slightly more generic:

\writeBookOddEven 
  \score {
    ...
  }

Probably my problem is really tiny, but I can't find the solution because the documentation of the ly:... functions isn't really helpful.
If I change the passed parameter from ly:book? to ly:score? then I don't know how to access the implicit \book object inside the function.
I assume that I should use ly:book-add-score! to add the score object passed into the function to the book. But I don't know how to access this book object (i.e. what to write instead of book-smob in "ly:book-add-score! book-smob score")

Attached is my attempt (writeScoreOddEven.ly) with comments on where I assume changes to be done.
Help is highly appreciated.

Best
Urs

Am 15.02.2013 09:37, schrieb Jan-Peter Voigt:
Hello Urs,

On 14.02.2013 20:50, Urs Liska wrote:
Hi list,

maybe it's an academic question, but maybe it also triggers the curiosity of some Scheme-hackers ;-)
I wouldn't call it academic - if want to build some kind of workflow, you will face the need for creating several pdfs from one ly-file.
Is it possible to write something (probably a Scheme function) that lets LilyPond compile a file twice with a different file included or a different command line option?
... you can process a book object in scheme as often you like (ly:process-book)
Or is it possible from within a document to launch a second LilyPond instance with an arbitrary command line option set?
You can play with schemes 'system' command, but I wouldn't use that, to call lilypond - it is already running.
The background is: I want to create a scenario where I can compile two different pdf files in one run. The two files should have a different first-page-number and a different filename suffix. I would like to have two versions of a score starting on odd and even pages. (Afterwards I want to include the appropriate file in a LaTeX document, depending on the page in the document.)

I can imagine doing this with two layout include files (like 'start-odd.ily' and 'start-even.ily') or with a function that directly writes the right commands depending on command line options (like '-dstartodd' or 'dstarteven').

So maybe the easiest way would be to have a function that triggers two separate lilypond runs on the same file, providing different command line options. I'd then have a main .ly file as usual that includes one of two style sheets depending on the presence of command line options, but I would explicitely run lilypond on a 'master' file that doesn't actually contain music but only controls the build process.
My approach is using a book variable. A scheme-function then sets all given paper vars in the book paper before it starts processing it with ly:process-book. The example file creates writeBook.pdf (odd version), writeBook-even.pdf and writeBook-music.midi.

HTH

Best, Jan-Peter



_______________________________________________
lilypond-user mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/lilypond-user

Attachment: writeBookOddEven.ly
Description: Text Data

Attachment: writeScoreOddEven.ly
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]