lilypond-user
[Top][All Lists]
Advanced

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

Re: Scoped variables


From: Peter Toye
Subject: Re: Scoped variables
Date: Thu, 7 Nov 2019 15:33:08 +0000

Timothy,

This raises a further question which I can't see answered in the documentation: exactly what characters are allowed in a Lilypond variable name? NR says that the convention is alphabetic characters only, but you seem to have found that digits and full-stops are allowed. Is this documented, or did you experiment?

Best regards,

Peter
mailto:address@hidden
www.ptoye.com

-------------------------
Monday, November 4, 2019, 6:46:05 PM, 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 }
  >>
  }
}

--
Timothy Lanfear, Bristol, UK.
reply via email to

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