LilyPond嵌套重复:重复中的百分号与segno(记号)

编程语言 2026-07-09

当把 \repeat percent 嵌套在 \repeat segno 之内时,执行会跳过 \alternative 结尾,从而不显示替代结局等。将所有乐谱写出而不使用 \repeat percent(musicOne)似乎可以按预期工作。

是不是 \repeat percent 不是为这种嵌套而设计的?

我在问这个是非题,因为这两种情况的代码都能成功编译,我想知道是否有人知道这是否属于这种范式的一部分。看起来似乎不太可能,但我想确认。

包含两个示例。第一个有预期输出,第二个则没有。在第二个示例中,嵌套重复的使用会导致两个替代结局以及“to Coda”符号后面的两小节也消失。

在此处输入图片描述

\version "2.24.4"
\language english
musicOne =  \relative c'{
    \time 4/4
    \repeat segno 2 {
        \repeat volta 2 {
          c1 | c | c | d | d | % This works and the /alternative block executes
          \alternative {
            { e1 }
            { f1 }
          }
        }
        g1 | g | a | a |

        \alternative {
          \volta 1 {
            a1 | a | b | b |
          }
          \volta 2 \volta #'() {
            \section
            \sectionLabel "Coda"
          }
        } 
      }
      c1 \fermata |
}


musicTwo =  \relative c'{
    \time 4/4
    \repeat segno 2 {
        \repeat volta 2 {
          \repeat percent 3 { c1 }
          \repeat percent 2 { d1 } % This causes to skip..
          \alternative { % ..this \alternative block..
            { e1 }
            { f1 }
          }
        }
        \repeat percent 2 { g1 } % ..and lands here.
        \repeat percent 2 { a1 }

        \alternative {
          \volta 1 {
            \repeat percent 2 { a1 }
            \repeat percent 2 { b1 }
          }
          \volta 2 \volta #'() {
            \section
            \sectionLabel "Coda"
          }
        } 
      }
      c1 \fermata |
    }
\score { \musicOne }
\score { \musicTwo }

解决方案

There's a quirk in the syntax of \alternative because the old \alternative syntax is still supported in 2.24 (others can explain this better than me).

To fix it, put an empty open and close brace ({}) before the \alternative:

\repeat percent 2 { g1 } % ..and lands here.
\repeat percent 2 { a1 } {}
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。

相关文章