Hello List, it's been a while!
The specific use case is to typeset this Bach movement in a style
similar to the NBA, that is, with up to four voices in the staff.
Setting precise positioning concerns aside for the moment (though they
will be important eventually), I'm looking for a way to enter this into
LilyPond ergonomically. The << ... \\ ... >> syntax doesn't seem to work
with more than two voices, so my approach is to try and make something
that behaves similarly (and hopefully also implemented similarly).
If you have other or better ideas, please suggest them! Otherwise, there
are a few problems with my implementation.
%%%
#(define-syntax cond-list
;; Macro because exprs are not to be evaluated if the conditions are
false
(syntax-rules ()
((_)
'())
((cond-list (cond . expr))
(let ((c cond))
(if c
(let ((e expr)) (list e))
'())))
((cond-list (cond . expr) rest ...)
(let ((c cond)
(r (cond-list rest ...)))
(if c
(let ((e expr))
(cons e r))
r)))))
voices =
#(define-music-function
(a b c d)
((ly:music?) (ly:music?) (ly:music?) (ly:music?))
(make-music
'SimultaneousMusic
'elements
(cond-list
(a . #{ \new Voice { \voiceOne #a } #})
(b . #{ \new Voice { \voiceFour #b } #})
(c . #{ \new Voice { \voiceThree #c } #})
(d . #{ \new Voice { \voiceTwo #d } #}))))
\relative b' {
\key b \minor
\time 3/4
\voices { fis'4 g fis8 e } { d4 d s } { fis,4 s cis' } { b,4 e a }
}
%%%
The first problem is that the function doesn't actually work
syntactically if I want to omit one of the voices. Using e.g. \voices a
g \default e substitutes the default value for the last two arguments
and sets the e separately, and I can't use ##f explicitly because it
doesn't pass the ly:music? check.
The second problem is one of efficiency: the function creates up to four
new Voice contexts every time. The results don't look right if I create
the contexts beforehand and use \context.
Any help will be appreciated!