lilypond-user
[Top][All Lists]
Advanced

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

Different editions from *ONE* source...


From: Dmytro O. Redchuk
Subject: Different editions from *ONE* source...
Date: Mon, 11 Jan 2010 11:02:40 +0200

(... or "Am I Reinventing The Wheel?")

Hi masters!

This is rather question (thought it might look like a solution).

So, intro and question...
=========================

I have a multiple scores (that's why i'm trying to have a possibility to
change things "globally") and every piece must be compilable as a single
piece and includeable into "books" (made with lilypond-book). And at the
same time some pieces have parts which must be removable on demand, and
for this task, i desided, using tags is optimal.

So, sometimes (without a good "wheel") i need to open somefile.ly and
change, lets say, "target tag" with which some parts should be kept.
Before compilation. And, possibly, after compilation revert things back.

Since i can not say this is "making different editions from really one
source", i would like to ASK --- how this can be made better?

... and my wheel
================

I decided that i need to have some "default tag" defined in every score
(regardless if i will use it or will not), and some way to re-define,
let's say, "target tag" in the score.

Idea: i'm using linux, and it's quite easy to make (soft) links. So,
somefile.ly and somefile--Tsometag.ly are THE SAME file if the latter is
the link to the former.

So, i need to have some way to ask lilypond to "guess" a value of a
"target tag". And, on the other hand, some way to ask lilypond to use
already defined target tag (because of lilypond-book renames snippets).

Just take a look:

% ----------------8<-----------------------------
%
% "targettag.lyi" to be included in every score.
%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Grabbed from http://lsr.dsi.unimi.it/LSR/Item?id=197
% Thanks! I would never guess these :O)

#(define comml    (object->string (command-line)))
#(define loc      (+ (string-rindex comml #\space) 2))
#(define commllen (- (string-length comml) 2))
#(define filen    (substring comml loc commllen))

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

#(define tagtag "--T")
#(define tagtaglen (string-length tagtag))

#(define dotpos (string-rindex filen #\.))
#(define tagpos (string-contains filen tagtag))

#(define targettag
  (if (defined? 'targettag)
      targettag
      (if (equal? tagpos #f)
          'tag-default
          (string->symbol (substring filen (+ tagpos tagtaglen) dotpos)))))

% ----------------8<-----------------------------

And how i can use this:

% ----------------8<-----------------------------
%
% example.ly:
%

\version "2.12.2"               % now i use 2.12.{2,3}

\include "targettag.lyi"

% Thanks to Carl for explaining quasiquote meaning!
origin = #(string-concatenate `("File \"" ,filen "\", compiled with tag \"" 
,(symbol->string targettag) "\"."))

\header { tagline = \origin }

melody = \relative c'' {
  c c
    -\tag #'tag-default -"With script by default"
    -\tag #'moo -"With MOO if moo is set"
  c c
}

{
  \keepWithTag #targettag \melody
}
% ----------------8<-----------------------------

Now let's make "different editions" (in a shell):

$ ln -s example.ly example--Tfoo.ly
$ ln -s example.ly example--Tmoo.ly


Now i can compile different editions:

$ lilypond example.ly        # "default" compilation

$ lilypond example--Tfoo.ly  # with any tagged section removed

$ lilypond example--Tmoo.ly  # with #'moo


While making books with lilypond-book:

% ----------------8<-----------------------------
\begin{lilypond}
  targettag = #'moo
  \include "example.ly"
\end{lilypond}
% ----------------8<-----------------------------



Well...
=======

Here are some things which hardly can be named "right" anyway... Soft
links are "svn-friendly", but i've not tried them under windows or...

And this approach requires some conventions to be followed (regarding
file names and tags...).

Well, now i'm working alone, some other peoples sometimes help me (using
windows), and i simply provide them with a template and... they will
never use tags, i guess... So, these problems hopefully will remain all
mine...

Anyway --- how do you, masters, usually solve these issues? (Yes, i've
searched in LSR but easily could miss something interesting in mail
archives, sorry!)

And *what may be wrong with my wheel*?..

Thank you a *lot*.

-- 
  Dmytro O. Redchuk





reply via email to

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