【问题标题】:Lilypond: How can I map numbers to notes with SchemeLilypond:如何使用 Scheme 将数字映射到笔记
【发布时间】:2016-05-27 21:59:36
【问题描述】:

我正在尝试创建一个函数,例如,\generateNote #3 #4 将生成一个 f4 - 这将有助于编写函数以快速生成比例等。

generateNote = 
#(define-music-function
  (parser location note)
  (number?)
  (define notes 
      '((0 . "c4") 
        (1 . "d4") 
        (2 . "e4") 
        (3 . "f4") 
        (4 . "g4") 
        (5 . "a4") 
        (6 . "b4")))
  #{  #(cdr (assoc (modulo note 7) notes)) #}
  )

这不起作用,因为error: music function cannot generate f4。但是,以下方法确实有效:

generateF = 
#(define-music-function
  (parser location)
  #{  f4 #}
  )

关于为什么这不起作用的任何想法?

我已经尝试将" "{ }#{ #} 交换,但无济于事。

【问题讨论】:

标签: lilypond


【解决方案1】:

我设法搞定了一些事情

generateNote = 
    #(define-music-function
     (parser location note duration) 
        (number? number?) 
        (define notes 
          '((0 . "c") 
            (1 . "d") 
            (2 . "e") 
            (3 . "f") 
            (4 . "g") 
            (5 . "a") 
            (6 . "b"))) 
        #{ 
            $(ly:parser-include-string 
              parser 
              (string-append 
                (cdr (assoc (modulo note 7) notes))
                (number->string duration)
                )
              )
        #}
       )

它至少有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-10
    • 2023-03-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多