On 20/10/2024 12:51, Alec Bartsch wrote:
\version "2.24.1"
\include "english.ly <http://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' }
}
The information you are probably missing is that transpose (and other
music functions) transform music in-place, so successive transpositions
will not act as you expect. You can use the function ly:music-deep-copy
to make a copy of the music, e.g.
(let ((music (ly:music-deep-copy (list-ref musicList (- index 1)))))
etc.
--
Timothy Lanfear, Bristol, UK.