scheme - 如何在 Lilypond 中缩写 'note with the same note an octave higher, parenthesized'?

标签 scheme guile lilypond music-notation

目前我写代码如下:

\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
}

其中我反复表示“这个音符,以及高一个 Octave 的同一音符,带括号”。

我想要一种缩写的方法,这样我就可以写出这样的东西:

\version "2.14.2"

poct = ...

\relative c, {
  \clef bass 
  \poct c \poct e \poct g2 \poct c,4 \poct d \poct e2
}

按照 a helpful answer to an earlier question of mine 中的建议,我尝试使用a music function ,但我无法让它发挥作用。我能得到的最接近的是

poct = #(define-music-function
     (parser location note)
     (ly:music?)
   #{
     << $note \transpose c c \parenthesize $note >>
   #})

但这使用 << ..>>而不是< ..> ,它没有按照我想要的方式呈现(并带有警告),我不知道为什么 \transpose c c实际上转置任何东西。

最后,切线相关的是,在尝试音乐功能时,我发现仅仅创建一个模仿 \repeat unfold 2 的音乐功能甚至是不可能的。 ;下面的内容在第三个和第四个之间跳下一个 Octave 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
}

最佳答案

好的,这是我为您创建的一个功能,它可以让您重复单个音调。唯一的问题是它不会使用 \relative 表示法。这是因为,在相对记谱法中,后面的音符序列 c' c' c' 显然会比前一个音符高一个 Octave 。不幸的是,我仍然找不到一种方法来使用诸如 \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 }
}

所以语法很简单 \times #"number ofrepetition"{ ...music... }。如果只重复一个音符,可以省略{}:\times #"重复次数""单音符"

您可以在 \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
}

请注意,以上所有音符都在同一 Octave 内。音符 f 的 Octave 位置也不受此函数的影响,它受到该函数之前的音符(即 d)的影响。

当然有一种方法可以为此编写更好的代码,但我无法使用任何 \relative\transpose 命令来实现这一点.

<小时/>

这里有一些尝试可以帮助您处理带括号的 Octave 音程(与上面的功能相同,但有一些小改动):

\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
}

这里仍然有一些问题:只有当参数是没有 { } 的单个注释时,此函数才会加上括号。上面的代码对此进行了很好的注释。

<小时/>

我希望这会对您有所帮助。如果我在这里遇到 Octave 音阶换位问题的解决方案,我会更新这个答案。

关于scheme - 如何在 Lilypond 中缩写 'note with the same note an octave higher, parenthesized'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19464086/

相关文章:

macos - 如何让方案解释器在 Emacs 中工作?

functional-programming - 使用 Scheme 抓取网页

scheme - 使用 Scheme 的列表中的数字总和

python - 词法分析和解析实用程序

lilypond - lilypond key 取消表格

scheme - 方案语言中嵌套函数的效率和成本如何

macros - 为什么这个 lisp 递归宏不起作用?

android - 是否可以将 Guile 嵌入到 iOS 或 Android 上的 C++ 应用程序中?

shell - 使用当前打开的文件作为参数从 Vim 运行 shell 脚本

Lilypond:自动递归地自定义条形线?