2009-12-14 38 views
6

lilypond可以使用默認顏色的任意方式using着色票據由音高

\override NoteHead #'color = #red c 

顏色說明是黑色的。但我喜歡通過音調來爲所有音符着色,以便我的孩子可以更容易地學會識別音符,因爲c,d,e,f ......與其自己的顏色相關聯。以上允許我這樣做,但相當冗長。

是否有一個快捷方式,某種宏,這讓我做線沿線的東西:

redc greend bluee 

甚至由瀝青覆蓋每個音符的默認顏色,這樣我甚至可以簡單地做:

c d e 

並且每個都有不同的顏色?

+0

+1我愛lilypond! – 2009-12-14 18:26:36

+0

儘管如此,與西貝柳斯相比,這是相當痛苦的,但根據我的經驗,到目前爲止,我已經完成了音樂排版,但我更喜歡圖形:) – Joey 2009-12-14 18:30:45

+0

我幾乎是一個音樂愛好者...... Lilypond做我需要的東西,在Linux上運行,並且是免費的。 – 2009-12-14 19:18:17

回答

9

有一個在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

1

OK,這本書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))))