Unfolding tremolo repeats: Difference between revisions
Appearance
Created page with "Under normal circumstances, <code><note>:<duration></code>, the shortcut of <code>\repeat tremolo</code> is not unfolded by <code>\unfoldRepeats</code>. This function works around that: <lilypond version="2.24"> 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-pr..." |
m added categories |
||
| Line 32: | Line 32: | ||
} | } | ||
</lilypond> | </lilypond> | ||
[[Category:Repeats]] | |||
[[Category:Tweaks and overrides]] | |||
Revision as of 22:06, 23 December 2025
Under normal circumstances, <note>:<duration>, the shortcut of \repeat tremolo is not unfolded by \unfoldRepeats. This function works around that:
\version "2.24"
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 }
{
\unfoldRepeats \music
}