2009-12-14 37 views
6

lilypond thể màu ghi chú một cách tùy ý usingghi chú màu trong lilypond bởi sân

\override NoteHead #'color = #red c 

với màu mặc định là màu đen. Nhưng tôi thích tô màu tất cả các ghi chú bằng cách quảng cáo chiêu hàng để trẻ em của tôi có thể dễ dàng học cách nhận ra các ghi chú khi c, d, e, f, ... được kết hợp với màu riêng của nó. Ở trên cho phép tôi làm điều này, nhưng khá là tiết.

Có một phím tắt, macro của một số loại, cho phép tôi làm điều gì đó dọc theo dòng:

redc greend bluee 

hoặc thậm chí ghi đè lên các màu sắc mặc định cho mỗi lưu ý bởi sân để tôi có thể thậm chí chỉ cần làm :

c d e 

và mỗi loại có màu khác nhau không?

+0

+1 I love lilypond! –

+0

So với Sibelius nó khá đau đớn, theo kinh nghiệm của tôi, mặc dù. Tôi đã thực hiện sắp xếp âm nhạc với cả hai cho đến nay nhưng tôi thích nó đồ họa tốt hơn :) – Joey

+0

Tôi khá nhiều một nhạc nghiệp dư ... Lilypond làm những gì tôi cần, chạy trên Linux, và hoàn toàn miễn phí. –

Trả lời

9

Có một ví dụ cho điều này trong các 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, cho cuốn sách Kid's Keyboard Course - Book #1 tôi mua hồi đầu năm nay tại Cambridge, bây giờ tôi có mã hóa màu này:

#(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)))) 
Các vấn đề liên quan