Unfolding tremolo repeats
Currently, note:duration, which is a more
or less a shortcut for \repeat tremolo, is not unfolded by
\unfoldRepeats (this is tracked in
issue #6145).
The function given in this snippet provides a workaround.
fixTremolos =
#(define-music-function (music) (ly:music?)
(music-map
(lambda (m)
(let ((event (any (lambda (a)
(and (music-is-of-type? a 'tremolo-event)
a))
(ly:music-property m 'articulations))))
(if event
(let* ((total-tremolo-duration (ly:music-property m
'duration))
(tremolo-type (ly:music-property event
'tremolo-type))
(one-tremolo-note-duration
(ly:make-duration (ly:intlog2 tremolo-type)))
(tremolo-note-count
(/ tremolo-type (expt 2 (ly:duration-log
total-tremolo-duration)))))
(set! (ly:music-property m 'duration)
one-tremolo-note-duration)
(set! (ly:music-property m 'articulations)
(delete! event (ly:music-property m 'articulations)))
(make-music 'TremoloRepeatedMusic
'repeat-count tremolo-note-count
'element m))
m)))
music))
unfoldRepeats = \unfoldRepeats #'() \fixTremolos \etc
music = { \repeat tremolo 8 c'16 c'2:16 }
{
\music
\unfoldRepeats \music
}