Hello lilypond experts,

In an effort to avoid awkward variable names like these:

one =   \relative c { c4 bf a c | bf af g bf | a g fs a | af gf f af | g }
two =   \relative c { c4 bf a g | f af g bf | a g fs e | gf f gf af | g }
...etc...

I'm putting my music expressions into a list and extracting them by index.
My real use case has dozens of examples but I've shortened it to just two
below. Everything is working except that the \transpose no longer
transposes, which was working when I was using individual variables as
above. I figure this is some kind of quoting issue with my list but every
variation I've tried has been unsuccessful.

Bonus points if the \relative c could be removed from the list elements and
moved elsewhere.

Thanks for any advice!

Alec


\version "2.24.1"
\include "english.ly"

\layout {
    ragged-last = ##f
}

line = #(define-music-function
            (label    changes   musicList index    transposition)
            (markup?  ly:music? list?     integer? ly:pitch?)

            (let ((music (list-ref musicList (- index 1))))
                #{
                    \transpose c #transposition {
                        <<
                            #changes
                            \new Staff \with { instrumentName = \markup {
\fontsize #3 #label \hspace #2 } } {
                                \clef bass
                                \time 4/4
                                \key g \minor
                                #music
                            }
                        >>
                    }
                #})
    )

barFiveChanges = \chords {
    c2:m7 f:7 | bf:m7 ef:7 | a:m7 d:7 | ef:m7 af:7 | g1:m7
}

barFiveMusic = #(list
    #{ \relative c { c4 bf a c | bf af g bf | a g fs a | af gf f af | g } #}
    #{ \relative c { c4 bf a g | f af g bf | a g fs e | gf f gf af | g } #}
)

\bookpart {
    \score { \line "1"  \barFiveChanges \barFiveMusic 1 c  }
    \score { \line "1a" \barFiveChanges \barFiveMusic 1 c' }
    \score { \line "2"  \barFiveChanges \barFiveMusic 2 c  }
    \score { \line "2a" \barFiveChanges \barFiveMusic 2 c' }
}

Reply via email to