|
From: | Lukas-Fabian Moser |
Subject: | Re: \repeat unfold 0 times? |
Date: | Wed, 27 Jan 2021 20:29:29 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 |
Hi Zachary,
I have found a way to use a scheme conditional to check if repeatcount is greater than zero before evaluating repeat. Here's the snippet:
\version "2.20.0"
m = #0n = #1o = #2
\new Staff {\repeat unfold #m dis'1#(let ((x #{ \repeat unfold #m dis1 #}))(if (> m 0) x))#(let ((x #{ \repeat unfold #n d1 #}))(if (> n 0) x))#(let ((x #{ \repeat unfold #o des1 #}))(if (> o 0) x))}
I'm looking for a more elegant solution that doesn't have me going in and out of scheme and lilypond. Please offer me some suggestions.
How about:
\version "2.22.0"
m = 0
n = 1
o = 2
empty-music = {}
unfold =
#(define-music-function (n mus) (index? ly:music?)
(if (positive? n)
#{ \repeat unfold #n { #mus } #}
#{ #} ))
\new Staff {
\unfold \m dis1
\unfold \n des1
\unfold \o dis1
}
Lukas
[Prev in Thread] | Current Thread | [Next in Thread] |