lilypond-user
[Top][All Lists]
Advanced

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

Re: Scoped variables


From: David Wright
Subject: Re: Scoped variables
Date: Mon, 4 Nov 2019 13:57:18 -0600
User-agent: Mutt/1.10.1 (2018-07-13)

On Mon 04 Nov 2019 at 18:46:05 (+0000), Timothy Lanfear wrote:
> On 04/11/2019 09:28, Peter Toye wrote:
> > Re: Scoped variables On further consideration I think that Timothy
> > Lanfear has, probably inadvertently, made my point for me.
> > 
> > If a publisher wanted to collect Mr. Lanfear's string quartets
> > (assuming that he has written more than one) into a single volume,
> > the Lilypond code would have to be changed to rename all of the
> > variables to something like QiIViolinI (using Roman numerals to
> > keep to the published convention of alphabetic characters only -
> > I'm surprised that Mr. Lanfear's version works at all). Using my
> > idea, and assuming that the variables were defined within the
> > score, noting has to change apart from the book and possibly
> > bookpart sections. Much easier and less error-prone. Also, if each
> > staff's content is in its own file in the same directory as its
> > score, the same code will serve for all movements:
> >   \score {
> >   \include "ViolinI.ly"
> >   \include "ViolinII.ly"
> >   \include "Viola.ly"
> >   \include "Cello.ly"
> >   }
> > 
> > Now you can have a directory/file structure like:
> > 
> > Book
> >   Book.ly
> >   Quartet1
> >     Movement1
> >       Score.ly
> >       Violin1.ly
> >       ...
> >     Movement2
> >       Score.ly
> > 
> > etc.
> > 
> > *
> > *
> 
> I was surprised to find that provided there is no explicit \book
> statement, variables can be redefined between bookparts and behave as
> desired.
> 
> \version "2.19.83"
> 
> I.Violin.1 = { \clef "treble" b'1 }
> I.Violin.2 = { \clef "treble" g' }
> I.Viola = { \clef "alto" d' }
> I.Cello = { \clef "bass" g1 }
> 
> \bookpart {
>   \score {
>   <<
>     \new Staff { \I.Violin.1 }
>     \new Staff { \I.Violin.2 }
>     \new Staff { \I.Viola }
>     \new Staff { \I.Cello }
>   >>
>   }
> }
> 
> I.Violin.1 = { \clef "treble" \key d\major cis''1 }
> I.Violin.2 = { \clef "treble" \key d\major a' }
> I.Viola = { \clef "alto" \key d\major e' }
> I.Cello = { \clef "bass" \key d\major a1 }
> 
> \bookpart {
>   \score {
>   <<
>     \new Staff { \I.Violin.1 }
>     \new Staff { \I.Violin.2 }
>     \new Staff { \I.Viola }
>     \new Staff { \I.Cello }
>   >>
>   }
> }

Well, the NR §3.1.5 does say:

   "A .ly file may contain any number of toplevel expressions, where a
    toplevel expression is one of the following: …

    • A \score block. This score will be collected with other toplevel
      scores, and combined as a single \book. …

    • A \book block logically combines multiple movements (i.e.,
      multiple \score blocks) in one document. If there are a number
      of \scores, one output file will be created for each \book block,
      in which all corresponding movements are concatenated."

So I assume you are depending on the first bullet, the implicit \book
block, to concatenate the scores. (I'm not sure what the \bookpart buys
you apart from a page-throw. Try commenting out your \bookpart lines.)

The NR goes on:

     "The only reason to explicitly specify \book blocks in a .ly file
      is if you wish to create multiple output files from a single
      input file."

That's what I use \book sections for, so the my output files can be
explicitly named (with \bookOutputSuffix) in a more systematic manner.
Editing your MWE with s/\bookpart/\book/ would demonstrate.
(I've never used bookparts myself.)

The NR goes on:

     "One exception is within lilypond-book documents, where you
      explicitly have to add a \book block if you want more than a
      single \score or \markup in the same example. …"

But it's not clear whether the OP is needing lilypond-book, because
their post concentrates only on Scoped Variables, which would seem to
involve a major code rewrite.
(I've never used lilypond-book seriously myself, preferring a workflow
using PDF fragments, their tools, and LuaLaTeX for final assembly.)

Cheers,
David.



reply via email to

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