【问题标题】:Coloring notes in Lilypond by pitch按音调在 Lilypond 中着色笔记
【发布时间】:2023-03-18 22:12:02
【问题描述】:

lilypond可以任意给笔记上色using

\override NoteHead #'color = #red c

默认颜色为黑色。但我喜欢按音高给所有音符上色,这样我的孩子们就可以更容易地学会识别音符,因为 c、d、e、f ……与它自己的颜色相关联。以上允许我这样做,但相当冗长。

是否有捷径,某种宏,可以让我按照以下方式做一些事情:

redc greend bluee

甚至按音高覆盖每个音符的默认颜色,这样我什至可以简单地做:

c d e

每个人都有不同的颜色吗?

【问题讨论】:

  • 根据我的经验,与 Sibelius 相比,它相当痛苦。到目前为止,我已经用这两种方式完成了音乐排版,但我更喜欢图形化的方式:)
  • 我几乎是一个音乐爱好者...... Lilypond 可以满足我的需求,在 Linux 上运行,而且是免费的。

标签: lilypond music-notation


【解决方案1】:

snippets 中有一个例子:

%Association list of pitches to colors.
#(define color-mapping
  (list
    (cons (ly:make-pitch 0 0 0) (x11-color 'red))
    (cons (ly:make-pitch 0 0 1/2) (x11-color 'green))
    (cons (ly:make-pitch 0 1 -1/2) (x11-color 'green))
    (cons (ly:make-pitch 0 2 0) (x11-color 'red))
    (cons (ly:make-pitch 0 2 1/2) (x11-color 'green))
    (cons (ly:make-pitch 0 3 -1/2) (x11-color 'red))
    (cons (ly:make-pitch 0 3 0) (x11-color 'green))
    (cons (ly:make-pitch 0 4 1/2) (x11-color 'red))
    (cons (ly:make-pitch 0 5 0) (x11-color 'green))
    (cons (ly:make-pitch 0 5 -1/2) (x11-color 'red))
    (cons (ly:make-pitch 0 6 1/2) (x11-color 'red))
    (cons (ly:make-pitch 0 1 0) (x11-color 'blue))
    (cons (ly:make-pitch 0 3 1/2) (x11-color 'blue))
    (cons (ly:make-pitch 0 4 -1/2) (x11-color 'blue))
    (cons (ly:make-pitch 0 5 1/2) (x11-color 'blue))
    (cons (ly:make-pitch 0 6 -1/2) (x11-color 'blue))
    ))

%Compare pitch and alteration (not octave).
#(define (pitch-equals? p1 p2)
  (and
    (= (ly:pitch-alteration p1) (ly:pitch-alteration p2))
    (= (ly:pitch-notename p1) (ly:pitch-notename p2))))

#(define (pitch-to-color pitch)
  (let ((color (assoc pitch color-mapping pitch-equals?)))
    (if color
      (cdr color))))

#(define (color-notehead grob)
  (pitch-to-color
    (ly:event-property (ly:grob-property grob 'cause) 'pitch)))

\score {
  \new Staff \relative c' {
    \override NoteHead #'color = #color-notehead
    c8 b d dis ees f g aes
  }
}

【讨论】:

    【解决方案2】:

    【讨论】:

    • 我看过那个例子,但显然没有足够的音乐素养来识别这与键盘上的音高变化不同 :) 这确实有效!
    【解决方案3】:

    好的,对于我今年早些时候在剑桥买的书Kid's Keyboard Course - Book #1,我现在有了这个颜色编码:

    #(define color-mapping
      (list
        (cons (ly:make-pitch 0 0 0) (x11-color 'magenta))
        (cons (ly:make-pitch 0 1 -1/2) (x11-color 'grey))
        (cons (ly:make-pitch 0 1 0) (x11-color 'grey))
        (cons (ly:make-pitch 0 1 1/2) (x11-color 'grey))
        (cons (ly:make-pitch 0 2 0) (x11-color 'red))
        (cons (ly:make-pitch 0 2 1/2) (x11-color 'red))
        (cons (ly:make-pitch 0 3 -1/2) (x11-color 'green))
        (cons (ly:make-pitch 0 3 0) (x11-color 'green))
        (cons (ly:make-pitch 0 4 -1/2) (x11-color 'blue))
        (cons (ly:make-pitch 0 4 0) (x11-color 'blue))
        (cons (ly:make-pitch 0 4 1/2) (x11-color 'blue))
        (cons (ly:make-pitch 0 5 0) (x11-color 'yellow))
        (cons (ly:make-pitch 0 5 -1/2) (x11-color 'yellow))
        (cons (ly:make-pitch 0 5 1/2) (x11-color 'yellow))
        (cons (ly:make-pitch 0 6 1/2) (x11-color 'purple))
        (cons (ly:make-pitch 0 6 0) (x11-color 'purple))
        (cons (ly:make-pitch 0 6 -1/2) (x11-color 'purple))))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-27
      • 2022-11-07
      • 1970-01-01
      • 2013-04-20
      • 2019-06-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-24
      相关资源
      最近更新 更多