Mar*_*ica 6 scheme guile lilypond music-notation
目前我写的lilypond代码看起来像这样:
\version "2.14.2"
P = #parenthesize
\relative c, {
\clef bass
<c \P c'> <e \P e'> <g \P g'>2 <c, \P c'>4 <d \P d'> <e \P e'>2
}
Run Code Online (Sandbox Code Playgroud)
我一再表示' 这个音符,同一个音符高一个八度,括号'.
我想要一种缩写的方法,这样我就可以这样写:
\version "2.14.2"
poct = ...
\relative c, {
\clef bass
\poct c \poct e \poct g2 \poct c,4 \poct d \poct e2
}
Run Code Online (Sandbox Code Playgroud)
正如对我之前的一个问题的有用回答所建议的那样,我试图使用音乐功能,但我无法让它发挥作用.我能得到的最接近的是
poct = #(define-music-function
(parser location note)
(ly:music?)
#{
<< $note \transpose c c \parenthesize $note >>
#})
Run Code Online (Sandbox Code Playgroud)
但这使用<<.. >>而不是<.. >,它不会呈现我想要的方式(并带有警告),我不知道为什么\transpose c c实际转换任何东西.
最后,切实相关,在试验音乐功能时,我发现甚至不可能只是创造一个模仿的音乐功能\repeat unfold 2; 以下是第三和第四之间的八度音程c:
\version "2.14.2"
double = #(define-music-function
(parser location note)
(ly:music?)
#{
$note $note
#})
\relative c, {
\clef bass
\double c \double e \double g2 \double c,4 \double d \double e2
}
Run Code Online (Sandbox Code Playgroud)
好的,这是我为您创建的一个功能,它允许您重复单个音高。唯一的问题是它不会使用该\relative符号。这是因为,在相对记谱中,后面的音符序列c' c' c'显然会比前一个音符高一个八度。不幸的是,我仍然找不到一种方法来拥有这样的函数,\function #3 c'可以输出c' c c. 也就是说,这是我的函数和一些示例:
\version "2.17.28"
times = #(define-music-function
(parser location N note)
(integer? ly:music?)
(cond
((>= N 2)
#{ \repeat unfold $N { \absolute $note } #}
)
((= N 1)
#{ \absolute $note #}
)
)
)
{
a4 \times #3 b4
R1
\times #4 { c'8 d' }
R1
\times #1 { c''1 }
}
Run Code Online (Sandbox Code Playgroud)
所以语法很简单\times #"number of repetition" { ...music... }。如果只重复一个注释,则可以省略{和}: \times #"number of repetition" "single note"。
您可以在乐段中间使用此功能\relative,但随后您应该输入该功能的音高作为绝对音高。看一看:
\version "2.17.28"
times = #(define-music-function
(parser location N note)
(integer? ly:music?)
(cond
((>= N 2)
#{ \repeat unfold $N { \absolute $note } #}
)
((= N 1)
#{ \absolute $note #}
)
)
)
\relative c'' {
c4 d \times #4 e'' f g
}
Run Code Online (Sandbox Code Playgroud)
请注意,以上所有音符都在同一八度内。音符的八度位置f也不受此函数的影响,它受函数之前的音符(即 )的影响d。
当然,有一种方法可以为此编写更好的代码,但我无法使用任何命令\relative或\transpose命令来完成此任务。
这里有一些尝试可以帮助您处理带括号的八度音程(与上面的功能相同,但有一些小改动):
\version "2.17.28"
timesP = #(define-music-function
(parser location N note)
(integer? ly:music?)
(cond
((>= N 2)
#{
<<
\repeat unfold $N { \absolute $note }
\transpose c c' \repeat unfold $N { \absolute \parenthesize $note }
>>
#}
)
((= N 1)
#{
<<
\absolute $note
{ \transpose c c' \parenthesize $note }
>>
#}
)
)
)
{
a4 \timesP #3 b4
\timesP #8 c'16
\timesP #2 g4
\timesP #4 { c'8 d' } % no parenthesis here because there are two notes as arguments...
\timesP #1 { c''1 } % no parenthesis here because of the { }
}
\relative c'' {
c4 d \timesP #4 e'' f g
}
Run Code Online (Sandbox Code Playgroud)
这里仍然有一些问题:只有当参数是不带{ }. 上面的代码对此进行了很好的注释。
我希望这会对您有所帮助。如果我在这里遇到八度音阶换位问题的解决方案,我会更新这个答案。