lilypond-user
[Top][All Lists]
Advanced

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

Re: Scoped variables


From: Timothy Lanfear
Subject: Re: Scoped variables
Date: Mon, 4 Nov 2019 18:46:05 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0


On 04/11/2019 09:28, Peter Toye wrote:
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 }
  >>
  }
}

-- 
Timothy Lanfear, Bristol, UK.

reply via email to

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