3

I have a bunch of organ scores with 4 voices (sopMusic, altoMusic, tenorMusic, bassMusic). Each of those voices consists of two alternating snippets of music. For example, under sopMusic we would find \sopranoOne and \sopranoTwo, both of which contain a couple measures of music. A simplified example would look like this:

sopMusic = {
    \global
    \voiceOne
    \sopranoOne 
    \sopranoTwo
    \sopranoOne 
    \sopranoTwo
}
altoMusic = {
    \global
    \voiceTwo
    \altoOne 
    \altoTwo
    \altoOne 
    \altoTwo
}
tenorMusic = {
    \global
    \voiceOne
    \tenorOne 
    \tenorTwo
    \tenorOne 
    \tenorTwo
}
bassMusic = {
    \global
    \voiceTwo
    \bassOne 
    \bassTwo
    \bassOne 
    \bassTwo
}

Typically I enter the correct number of repetitions in the soprano, and then copy/paste for the alto, tenor and bass parts. But this would be better done programmatically. Can somebody give me a function that will produce the altoMusic, tenorMusic, and bassMusic automatically given the sopMusic as an input?

1

1 Answer 1

3

Maybe something like this fits the bill?

%%% Predicate for number or #f
#(define (number-or-false? x) (or (number? x) (not x)))

%%% arrange music saved in alist @param part in order @param repetitions (a list of assoc keys). Optionally
%%% the voice number can be specified using @param voicenumber
unfoldRepetition =
#(define-music-function (repetitions voicenumber part) (list? (number-or-false? #f) list?)
   (make-music 'SequentialMusic
               'elements
               (if voicenumber
                   (cons (context-spec-music (make-voice-props-set (1- voicenumber))  'Voice)
                         (map (lambda (x) (ly:assoc-get x part)) repetitions))
                   (map (lambda (x) (ly:assoc-get x part)) repetitions))))

%%% DEFINING MUSIC
% This defines associated lists, which is nice to access from Scheme. We use 1,2 as keys, but this could be any symbol, e.g. one,two
soprano.1 = {
  c''4 d'' c'' d''
}

soprano.2 = {
  b'4 c'' b' c''
}

alto.1 = {
  g'2 f'
}

alto.2 = {
  e'2 d'
}

tenor.1 = {
  e'2 d'
}

tenor.2 = {
  a2 b
}

bass.1 = {
  c2 g
}

bass.2 = {
  a2 g
}
%%% DONE DEFINING MUSIC

%%% Define a list of repetitions
#(define repetitions '(1 2 1 2))

% Test for one voice without specifying voice number
\unfoldRepetition #repetitions #soprano

% Test for multiple voices with voice number (although not necessary)
\new ChoirStaff <<
  \new Staff << \unfoldRepetition #repetitions 1 #soprano \\ \unfoldRepetition #repetitions 2 #alto >>
  \new Staff { \clef bass << \unfoldRepetition #repetitions 1 #tenor \\ \unfoldRepetition #repetitions 2 #bass >> }
>>

%%% DEFINE A choir score FACTORY:
choirScore =
#(define-scheme-function (S A T B) (list? list? list? list?)
   (define-music-function (reps) (list?)
     #{
       \new ChoirStaff <<
         \new Staff << \unfoldRepetition #reps 1 #S \\ \unfoldRepetition #reps 2 #A >>
         \new Staff { \clef bass << \unfoldRepetition #reps 1 #T \\ \unfoldRepetition #reps 2 #B >> }
       >>
     #}))

%% Test
myChoirFactory = \choirScore #soprano #alto #tenor #bass

\myChoirFactory #repetitions
\myChoirFactory #'(1 2 1)
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.