【问题标题】:Passing chords to and returning music with Lilypond music substitution functions使用 Lilypond 音乐替换功能传递和返回音乐
【发布时间】:2018-08-26 20:35:45
【问题描述】:

我正在尝试在 Lilypond 中编写函数,该函数将和弦(或音高列表)作为参数并返回将所述和弦插入节奏的音乐。更具体地说,我希望以如下方式调用该函数:

\chordFunction <c ef f af>
% or
\chordFunction #'(c ef f af)

并像这样返回 Lilypond 代码:

\tuplet 3/2 {<c ef f af>4 <c ef f af>8~} <c ef f af>2


我试过了

jazzsyncoA = 
#(define-music-function
  (parser location chord)
  (symbol-list-or-music?)
  #{
    \tuplet 3/2 {$<chord>4 $<chord>8~} $<chord>2
  #}
)

但这会引发

error: GUILE signaled an error for the expression beginning here
    \tuplet 3/2 {$
                  <chord>4 $<chord>8~} $<chord>2

当我尝试调用时出现其他错误。我应该如何编写函数来完成这个?我是否不正确地处理问题?


我查看了Lilypond docs on predefined type predicates,但我无法识别任何潜在用途。

【问题讨论】:

    标签: scheme guile lilypond music-notation


    【解决方案1】:

    我认为您的方向或多或少是正确的。您可以查看this LilyPond doc page,了解如何开始编写纯 Scheme 函数来解决这个问题和其他问题。

    至于你的函数,如果你想使用像\chordFunction &lt;c ef f af&gt;这样的函数,那么你可以ly:music?作为谓词:

    \version "2.18.0"
    \language "english"
    
    jazzsyncoA = #(define-music-function (parser location my-notes) (ly:music?)
        #{
            \tuplet 3/2 {  #my-notes q8~ } q2
        #}
    )
    
    \score {
        \new Staff {
            \clef "bass"
            \key c \minor
            \new Voice = "one" {
                \jazzsyncoA <c ef f af>4
            }
        }
    }
    
    

    这与您图片中的结果相同。我在 2.19.82 版本上对此进行了测试,但我猜它也可以在 2.18.0 上运行。希望对您有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多