Unfolding tremolo repeats: Difference between revisions
Appearance
m removed "tweaks and overrides" cat |
mNo edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
Currently, <code><var>note</var>:<var>duration</var></code>, which is more or less a shortcut for <code>\repeat tremolo</code>, is not unfolded by <code>\unfoldRepeats</code> (this is tracked in {{Issue|6145}}). The function given in this snippet provides a workaround. | |||
<lilypond version="2.24"> | <lilypond version="2.24"> | ||
fixTremolos = | fixTremolos = | ||
| Line 10: | Line 11: | ||
(ly:music-property m 'articulations)))) | (ly:music-property m 'articulations)))) | ||
(if event | (if event | ||
(let* ((total-tremolo-duration (ly:music-property m 'duration)) | (let* ((total-tremolo-duration (ly:music-property m | ||
(tremolo-type (ly:music-property event 'tremolo-type)) | 'duration)) | ||
(one-tremolo-note-duration (ly:make-duration (ly:intlog2 tremolo-type))) | (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) | (set! (ly:music-property m 'duration) | ||
one-tremolo-note-duration) | one-tremolo-note-duration) | ||
| Line 29: | Line 35: | ||
{ | { | ||
\music | |||
\unfoldRepeats \music | \unfoldRepeats \music | ||
} | } | ||
</lilypond> | </lilypond> | ||
[[Category:Repeats]] | [[Category:Repeats]] | ||
[[Category:Workaround]] | |||
[[Category:Included in the official documentation]] | |||
[[Category:Snippet]] | |||
Latest revision as of 08:49, 6 January 2026
Currently, note:duration, which is 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.
\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 }
{
\music
\unfoldRepeats \music
}