Re: color notehead according to absolute pitch
thanks jay it doesn't handle b-sharp yet - but other than that it's pretty compact for absolute pitch apologies in advance to kenny for slightly hijacking the thread but... my own needs are for (e.g.) all d-sharps/e-flats/e-naturals/f-flats to be red etc (parsing webern with hexatonic/octatonic scales for analysis students) i can make it work by modifying your previous suggestion, along these lines: #(define (pitch-to-color pitch) (cond ((and (eqv? (ly:pitch-alteration pitch) 0) (eqv? (ly:pitch-notename pitch) 0)) (x11-color 'red)) ((and (eqv? (ly:pitch-alteration pitch) 1/2) (eqv? (ly:pitch- notename pitch) 0)) (x11-color 'green)) ((and (eqv? (ly:pitch-alteration pitch) -1/2) (eqv? (ly:pitch- notename pitch) 1)) (x11-color 'green)) ((and (eqv? (ly:pitch-alteration pitch) 0) (eqv? (ly:pitch-notename pitch) 2)) (x11-color 'red)) ((and (eqv? (ly:pitch-alteration pitch) 1/2) (eqv? (ly:pitch- notename pitch) 2)) (x11-color 'green)) ((and (eqv? (ly:pitch-alteration pitch) -1/2) (eqv? (ly:pitch- notename pitch) 3)) (x11-color 'red)) ((and (eqv? (ly:pitch-alteration pitch) 0) (eqv? (ly:pitch-notename pitch) 3)) (x11-color 'green)) ((and (eqv? (ly:pitch-alteration pitch) 1/2) (eqv? (ly:pitch- notename pitch) 4)) (x11-color 'red)) ((and (eqv? (ly:pitch-alteration pitch) 0) (eqv? (ly:pitch-notename pitch) 5)) (x11-color 'green)) ((and (eqv? (ly:pitch-alteration pitch) -1/2) (eqv? (ly:pitch- notename pitch) 5)) (x11-color 'red)) ((and (eqv? (ly:pitch-alteration pitch) 1/2) (eqv? (ly:pitch- notename pitch) 6)) (x11-color 'red)) ((and (eqv? (ly:pitch-alteration pitch) 0) (eqv? (ly:pitch-notename pitch) 1)) (x11-color 'blue)) ((and (eqv? (ly:pitch-alteration pitch) 1/2) (eqv? (ly:pitch- notename pitch) 3)) (x11-color 'blue)) ((and (eqv? (ly:pitch-alteration pitch) -1/2) (eqv? (ly:pitch- notename pitch) 4)) (x11-color 'blue)) ((and (eqv? (ly:pitch-alteration pitch) 1/2) (eqv? (ly:pitch- notename pitch) 5)) (x11-color 'blue)) ((and (eqv? (ly:pitch-alteration pitch) -1/2) (eqv? (ly:pitch- notename pitch) 6)) (x11-color 'blue)) ) ) but, as you can see it's hardly great programming style and somewhat error prone. any further help would be hugely appreciated — other than the obvious, which is 'go and learn scheme! ' ;-) — as i've been struggling with this one for months now. thanks again damian On 9 Aug 2008, at 05:12, Jay Anderson wrote: If anyone can come up with a nice solution, this should definitely be added to the LSR... I'm not sure this is a nice solution yet, but it is at least a little easier to manipulate the color mapping and it handles enharmonic spellings easily. Let me know what you think. -Jay \version 2.11.54 %Association list of semitones from middle c to colors. #(define color-mapping (list (cons (ly:pitch-semitones (ly:make-pitch 0 0 0)) (x11-color 'blue)) (cons 2 (x11-color 'yellow)) (cons 3 (x11-color 'red)) (cons -1 (x11-color 'green)) (cons 5 (x11-color 'purple)) (cons 7 (x11-color 'cyan)) (cons 8 (x11-color 'ForestGreen)) )) #(define (pitch-to-color pitch) (let ((color (assv (ly:pitch-semitones pitch) color-mapping))) (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 } } ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: color notehead according to absolute pitch
Damian leGassick damianlegassick at mac.com writes: my own needs are for (e.g.) all d-sharps/e-flats/e-naturals/f-flats to be red etc (parsing webern with hexatonic/octatonic scales for analysis students) You can do a very similar thing: %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))) ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: color notehead according to absolute pitch
If anyone can come up with a nice solution, this should definitely be added to the LSR... I'm not sure this is a nice solution yet, but it is at least a little easier to manipulate the color mapping and it handles enharmonic spellings easily. Let me know what you think. -Jay \version 2.11.54 %Association list of semitones from middle c to colors. #(define color-mapping (list (cons (ly:pitch-semitones (ly:make-pitch 0 0 0)) (x11-color 'blue)) (cons 2 (x11-color 'yellow)) (cons 3 (x11-color 'red)) (cons -1 (x11-color 'green)) (cons 5 (x11-color 'purple)) (cons 7 (x11-color 'cyan)) (cons 8 (x11-color 'ForestGreen)) )) #(define (pitch-to-color pitch) (let ((color (assv (ly:pitch-semitones pitch) color-mapping))) (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 } } ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: color notehead according to absolute pitch
2008/8/4 Kenny Stephens [EMAIL PROTECTED]: Is there a means by which I can color the notes based on its absolute pitch --- not its pitch class? If anyone can come up with a nice solution, this should definitely be added to the LSR... Cheers, Valentin ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: color notehead according to absolute pitch
kenny, how about #(define (color-notehead grob) (pitch-to-color (ly:event-property (ly:grob-property grob 'cause) 'pitch))) #(define (pitch-to-color pitch) (cond ((and (eqv? (ly:pitch-octave pitch) 0) (eqv? (ly:pitch-alteration pitch) 0) (eqv? (ly:pitch-notename pitch) 6)) (x11-color 'red)) ((and (eqv? (ly:pitch-octave pitch) 0) (eqv? (ly:pitch-alteration pitch) -1/2) (eqv? (ly:pitch-notename pitch) 6)) (x11-color 'green)) ((and (eqv? (ly:pitch-octave pitch) 1) (eqv? (ly:pitch-alteration pitch) 0) (eqv? (ly:pitch-notename pitch) 6)) (x11-color 'blue)) ((and (eqv? (ly:pitch-octave pitch) 0) (eqv? (ly:pitch-alteration pitch) 0) (eqv? (ly:pitch-notename pitch) 5)) (x11-color 'orange)) ((and (eqv? (ly:pitch-octave pitch) 0) (eqv? (ly:pitch-alteration pitch) 0) (eqv? (ly:pitch-notename pitch) 4)) (x11-color 'orange)) ) ) and any kind schemers reading how would you refactor this to use lists, along the lines of (0 0 6 'red) (0 -1/2 6 'green) (1 0 6 'blue) ((0 0 5 ) (0 0 4) 'orange) thanks d On 5 Aug 2008, at 23:06, Damian leGassick wrote: thanks steven cond - yes, i was trying to use case kenny - can you figure it out from here? if not i'll try tomorrow morning london time d On 5 Aug 2008, at 21:10, Steven Weber wrote: Use the (cond) expression. Here's a simplified version of your pitch-to-color function that colors all c's red and all f's blue: #(define (pitch-to-color pitch) (cond ((eqv? (ly:pitch-notename pitch) 0) (x11-color 'red)) ((eqv? (ly:pitch-notename pitch) 3) (x11-color 'blue)) ) ) --Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Damian leGassick Sent: Tuesday, August 05, 2008 5:53 AM To: lilypond-user@gnu.org Subject: Re: color notehead according to absolute pitch On 5 Aug 2008, at 05:39, Jay Anderson wrote: Kenny Stephens kfstephensii at yahoo.com writes: Our church has a handbell group whose members are not all musically literate. To keep themselves from having to learn to read music, they mark their notes using differently colored highlighters. Is there a means by which I can color the notes based on its absolute pitch --- not its pitch class? Some of the music spans three octaves. The requirements are: 1) b4 and b5 are different colors. 2) b\flat4 and b4 are different colors. 3) different pitches can be assigned to the same color (some ringers play two or more handbells). I've only been playing around with Lilypond for about a week (though I've logged numerous hours) for typesetting organ music; but this is different. I did find an example using Scheme and 'staff-position,' but this fails condition 1. Ideas, suggestions or solutions would be appreciated. Using the same idea as the example you mentioned (http://lilypond.org/doc/v2.11/Documentation/user/lilypond-learning/Advanced -tweaks-with-Scheme ) you can base the color on the pitch: #(define (color-notehead grob) (pitch-to-color (ly:event-property (ly:grob-property grob 'cause) 'pitch))) Now you'd just have to figure out how to implement the pitch-to- color function. For example this colors all the flat notes blue: #(define (pitch-to-color pitch) (if (eqv? (ly:pitch-alteration pitch) -1/2) (x11-color 'blue))) You might want to get a little fancy to make sure enharmonic spellings of the same pitch are the same color, but for most cases that shouldn't be a problem. -Jay ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user I can get as far as: #(define (color-notehead grob) (pitch-to-color (ly:event-property (ly:grob-property grob 'cause) 'pitch))) #(define (pitch-to-color pitch) (if (and (eqv? (ly:pitch-octave pitch) 0) (eqv? (ly:pitch-alteration pitch) -1/2) (eqv? (ly:pitch-notename pitch) 6)) (x11-color 'blue))) which sets only the b-flat above middle c to be blue. can't work out how to simultaneously colour the b-natural, say, red - i'd love to know too Damian ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: color notehead according to absolute pitch
On 5 Aug 2008, at 05:39, Jay Anderson wrote: Kenny Stephens kfstephensii at yahoo.com writes: Our church has a handbell group whose members are not all musically literate. To keep themselves from having to learn to read music, they mark their notes using differently colored highlighters. Is there a means by which I can color the notes based on its absolute pitch --- not its pitch class? Some of the music spans three octaves. The requirements are: 1) b4 and b5 are different colors. 2) b\flat4 and b4 are different colors. 3) different pitches can be assigned to the same color (some ringers play two or more handbells). I've only been playing around with Lilypond for about a week (though I've logged numerous hours) for typesetting organ music; but this is different. I did find an example using Scheme and 'staff-position,' but this fails condition 1. Ideas, suggestions or solutions would be appreciated. Using the same idea as the example you mentioned (http://lilypond.org/doc/v2.11/Documentation/user/lilypond-learning/Advanced-tweaks-with-Scheme ) you can base the color on the pitch: #(define (color-notehead grob) (pitch-to-color (ly:event-property (ly:grob-property grob 'cause) 'pitch))) Now you'd just have to figure out how to implement the pitch-to-color function. For example this colors all the flat notes blue: #(define (pitch-to-color pitch) (if (eqv? (ly:pitch-alteration pitch) -1/2) (x11-color 'blue))) You might want to get a little fancy to make sure enharmonic spellings of the same pitch are the same color, but for most cases that shouldn't be a problem. -Jay ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user I can get as far as: #(define (color-notehead grob) (pitch-to-color (ly:event-property (ly:grob-property grob 'cause) 'pitch))) #(define (pitch-to-color pitch) (if (and (eqv? (ly:pitch-octave pitch) 0) (eqv? (ly:pitch-alteration pitch) -1/2) (eqv? (ly:pitch-notename pitch) 6)) (x11-color 'blue))) which sets only the b-flat above middle c to be blue. can't work out how to simultaneously colour the b-natural, say, red - i'd love to know too Damian ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
RE: color notehead according to absolute pitch
Use the (cond) expression. Here's a simplified version of your pitch-to-color function that colors all c's red and all f's blue: #(define (pitch-to-color pitch) (cond ((eqv? (ly:pitch-notename pitch) 0) (x11-color 'red)) ((eqv? (ly:pitch-notename pitch) 3) (x11-color 'blue)) ) ) --Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Damian leGassick Sent: Tuesday, August 05, 2008 5:53 AM To: lilypond-user@gnu.org Subject: Re: color notehead according to absolute pitch On 5 Aug 2008, at 05:39, Jay Anderson wrote: Kenny Stephens kfstephensii at yahoo.com writes: Our church has a handbell group whose members are not all musically literate. To keep themselves from having to learn to read music, they mark their notes using differently colored highlighters. Is there a means by which I can color the notes based on its absolute pitch --- not its pitch class? Some of the music spans three octaves. The requirements are: 1) b4 and b5 are different colors. 2) b\flat4 and b4 are different colors. 3) different pitches can be assigned to the same color (some ringers play two or more handbells). I've only been playing around with Lilypond for about a week (though I've logged numerous hours) for typesetting organ music; but this is different. I did find an example using Scheme and 'staff-position,' but this fails condition 1. Ideas, suggestions or solutions would be appreciated. Using the same idea as the example you mentioned (http://lilypond.org/doc/v2.11/Documentation/user/lilypond-learning/Advanced -tweaks-with-Scheme ) you can base the color on the pitch: #(define (color-notehead grob) (pitch-to-color (ly:event-property (ly:grob-property grob 'cause) 'pitch))) Now you'd just have to figure out how to implement the pitch-to-color function. For example this colors all the flat notes blue: #(define (pitch-to-color pitch) (if (eqv? (ly:pitch-alteration pitch) -1/2) (x11-color 'blue))) You might want to get a little fancy to make sure enharmonic spellings of the same pitch are the same color, but for most cases that shouldn't be a problem. -Jay ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user I can get as far as: #(define (color-notehead grob) (pitch-to-color (ly:event-property (ly:grob-property grob 'cause) 'pitch))) #(define (pitch-to-color pitch) (if (and (eqv? (ly:pitch-octave pitch) 0) (eqv? (ly:pitch-alteration pitch) -1/2) (eqv? (ly:pitch-notename pitch) 6)) (x11-color 'blue))) which sets only the b-flat above middle c to be blue. can't work out how to simultaneously colour the b-natural, say, red - i'd love to know too Damian ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: color notehead according to absolute pitch
thanks steven cond - yes, i was trying to use case kenny - can you figure it out from here? if not i'll try tomorrow morning london time d On 5 Aug 2008, at 21:10, Steven Weber wrote: Use the (cond) expression. Here's a simplified version of your pitch-to-color function that colors all c's red and all f's blue: #(define (pitch-to-color pitch) (cond ((eqv? (ly:pitch-notename pitch) 0) (x11-color 'red)) ((eqv? (ly:pitch-notename pitch) 3) (x11-color 'blue)) ) ) --Steven -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Damian leGassick Sent: Tuesday, August 05, 2008 5:53 AM To: lilypond-user@gnu.org Subject: Re: color notehead according to absolute pitch On 5 Aug 2008, at 05:39, Jay Anderson wrote: Kenny Stephens kfstephensii at yahoo.com writes: Our church has a handbell group whose members are not all musically literate. To keep themselves from having to learn to read music, they mark their notes using differently colored highlighters. Is there a means by which I can color the notes based on its absolute pitch --- not its pitch class? Some of the music spans three octaves. The requirements are: 1) b4 and b5 are different colors. 2) b\flat4 and b4 are different colors. 3) different pitches can be assigned to the same color (some ringers play two or more handbells). I've only been playing around with Lilypond for about a week (though I've logged numerous hours) for typesetting organ music; but this is different. I did find an example using Scheme and 'staff-position,' but this fails condition 1. Ideas, suggestions or solutions would be appreciated. Using the same idea as the example you mentioned (http://lilypond.org/doc/v2.11/Documentation/user/lilypond-learning/Advanced -tweaks-with-Scheme ) you can base the color on the pitch: #(define (color-notehead grob) (pitch-to-color (ly:event-property (ly:grob-property grob 'cause) 'pitch))) Now you'd just have to figure out how to implement the pitch-to-color function. For example this colors all the flat notes blue: #(define (pitch-to-color pitch) (if (eqv? (ly:pitch-alteration pitch) -1/2) (x11-color 'blue))) You might want to get a little fancy to make sure enharmonic spellings of the same pitch are the same color, but for most cases that shouldn't be a problem. -Jay ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user I can get as far as: #(define (color-notehead grob) (pitch-to-color (ly:event-property (ly:grob-property grob 'cause) 'pitch))) #(define (pitch-to-color pitch) (if (and (eqv? (ly:pitch-octave pitch) 0) (eqv? (ly:pitch-alteration pitch) -1/2) (eqv? (ly:pitch-notename pitch) 6)) (x11-color 'blue))) which sets only the b-flat above middle c to be blue. can't work out how to simultaneously colour the b-natural, say, red - i'd love to know too Damian ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: color notehead according to absolute pitch
Kenny Stephens kfstephensii at yahoo.com writes: Our church has a handbell group whose members are not all musically literate. To keep themselves from having to learn to read music, they mark their notes using differently colored highlighters. Is there a means by which I can color the notes based on its absolute pitch --- not its pitch class? Some of the music spans three octaves. The requirements are: 1) b4 and b5 are different colors. 2) b\flat4 and b4 are different colors. 3) different pitches can be assigned to the same color (some ringers play two or more handbells). I've only been playing around with Lilypond for about a week (though I've logged numerous hours) for typesetting organ music; but this is different. I did find an example using Scheme and 'staff-position,' but this fails condition 1. Ideas, suggestions or solutions would be appreciated. Using the same idea as the example you mentioned (http://lilypond.org/doc/v2.11/Documentation/user/lilypond-learning/Advanced-tweaks-with-Scheme) you can base the color on the pitch: #(define (color-notehead grob) (pitch-to-color (ly:event-property (ly:grob-property grob 'cause) 'pitch))) Now you'd just have to figure out how to implement the pitch-to-color function. For example this colors all the flat notes blue: #(define (pitch-to-color pitch) (if (eqv? (ly:pitch-alteration pitch) -1/2) (x11-color 'blue))) You might want to get a little fancy to make sure enharmonic spellings of the same pitch are the same color, but for most cases that shouldn't be a problem. -Jay ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
color notehead according to absolute pitch
Our church has a handbell group whose members are not all musically literate. To keep themselves from having to learn to read music, they mark their notes using differently colored highlighters. Is there a means by which I can color the notes based on its absolute pitch --- not its pitch class? Some of the music spans three octaves. The requirements are: 1) b4 and b5 are different colors. 2) b\flat4 and b4 are different colors. 3) different pitches can be assigned to the same color (some ringers play two or more handbells). I've only been playing around with Lilypond for about a week (though I've logged numerous hours) for typesetting organ music; but this is different. I did find an example using Scheme and 'staff-position,' but this fails condition 1. Ideas, suggestions or solutions would be appreciated. Thanks, Kenny ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user