gpt4 book ai didi

lilypond - 按音高在 Lilypond 中着色笔记

转载 作者:行者123 更新时间:2023-12-03 07:27:53 27 4
gpt4 key购买 nike

lilypond可以以任意方式为笔记着色using

\override NoteHead #'color = #red c

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

是否有某种快捷方式,某种宏,允许我执行以下操作:
redc greend bluee

甚至按音高覆盖每个音符的默认颜色,以便我什至可以简单地执行以下操作:
c d e

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

最佳答案

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

Sample image

关于lilypond - 按音高在 Lilypond 中着色笔记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1902526/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com