Hi Kieren,

I think with large projects it is a good idea to establish a nice data flow. 
Basically your code does different things. For one thing you have musical data, 
for another thing you have formatting of said data, and then you also have 
functions and stuff.

Depending on your particular needs you can create you own way of specifying 
data, layouts, stylesheets and such, and the cleaner you can separate these 
the better you will be able to transparently do complex things.

> 1. Should I have one output file per score, or use \book? I assume if it’s
> multiple files, and I want to keep them synchronized, I would want to use
> make (or similar) to trigger a compilation of all of them at once?

Depends on what you want.

> 2. Am I <<>>-ing the \global at the best spot(s)?

You could also add \global once in a toplevel DevNull

> 3. Compare the voicing of m3 in the SATB and SA voicings: mm1-2 are
> different, but m3 is the same. How can I do this kind of thing with the
> least amount of code duplication? I don’t believe quoted music can be
> transposed directly (i.e., you need to create a second, pre-transposed,
> quotation); I can’t see how to inject a transposition (e.g., using the
> Edition-Engraver) into a specific part of a score/variable; I really don’t
> want to have to break every variable into multiple subvariables to handle
> every difference between voicings (nor do I want to have complete
> duplicates, one per voicing!); etc.

With such small differences it might be useful to notate chords by voices << 
... >> instead.

Here is a sketch demonstrating a few concepts of how you could specify data 
and have custom music function make sense of it:

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

replaceWithTag =
#(define-music-function (tags rep music)
   (symbol-list-or-symbol? ly:music? ly:music?)
   (music-map
    (lambda (x) (if ((tags-remove-predicate tags) x)
                    x
                    rep))
    music))

alternatives =
#(define-music-function (names musics) (symbol-list? ly:music?)
   (ly:music-set-property! musics 'alternatives names)
   musics)

selectAlternative =
#(define-music-function (alt music) (symbol? ly:music?)
   (music-map
    (lambda (x)
      (if (ly:music-property x 'alternatives #f)
          (assoc-get alt (map cons (ly:music-property x 'alternatives) 
(ly:music-property x 'elements)))
          x))
    music))

preferredClef = \tag preferred-clef \clef "treble"

reflow =
#(define-music-function (style music) (list? ly:music?)
   #{
     \transpose #(ly:make-pitch 0 0) #(ly:make-pitch (assoc-get 'octave style 
0) 0)
     \removeWithTag #(assoc-get 'removes style '())
     \selectAlternative #(assoc-get 'alternative style 'default)
     \replaceWithTag preferred-clef \clef #(assoc-get 'preferred-clef style 
"treble")
     #music
   #})

styles.tenor.preferred-clef = "treble_8"
styles.tenor.octave = -1

styles.bass.preferred-clef = "bass"
styles.bass.octave = -1

styles.choir_satb.alternative = #'sa
styles.choir_sa.alternative = #'satb

\language "english"

global = {
  \tempo "Fast"
  \key c \major
  s1
  \tag full { s1 }
  \bar "||"
  \key d \major
  s1
  \bar "|."
}

voice.michael = {
  \preferredClef
  c''4 4 4 4
  \tag full { g'4 4 a'4 4 }
  d'4 4 4 4
}

voice.chorus = \new Voice <<
  {
    c'4 4 4 4 \tag full { b4 4 cs'4 4 } d'4 4 4 4
  }
  {
    e'4 4 4 4 \tag full { d'4 4 e'4 4 } fs'4 4 4 4
  }
  {
    \alternatives satb,sa <<
      {
        g4 4 4 4 \tag full { g4 4 a4 4 }
      }
      {
        g'4 4 4 4 \tag full { g'4 4 a'4 4 }
      }
    >>
    a4 4 4 4
  }
>>

\score {
  <<
    \new Devnull \global
    \new Staff { \voice.michael }
    \new Staff \reflow \styles.tenor { \voice.michael }
    \new Staff \reflow \styles.bass { \voice.michael }
    \new Staff \reflow \styles.choir_satb { \voice.chorus }
    \new Staff \reflow \styles.choir_sa { \voice.chorus }
  >>
}

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

Cheers,
Valentin

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to