Oops,
Forgot to reply all... (Messages to the list are now slightly out of
sequence.)
---------- Forwarded message ----------
From: David Nalesnik <david.nales...@gmail.com>
Date: Sun, May 25, 2014 at 9:52 AM
Subject: Re: handbells
To: mark damerell <markdamer...@googlemail.com>
Hi again,
On Sun, May 25, 2014 at 5:43 AM, mark damerell
<markdamer...@googlemail.com>wrote:
> Thank you, it does some of it. Mark
>
>>
>>
OK, in that case, here's an expanded set of functions.
To make a part for an individual player, you call \colorPitch, which takes
a music expression containing the pitches to color and the color to use.
In the example, I store information for players in variables for
convenience.
You can color any number of pitches for a player.
The octave matters, of course.
Note that if a ringer has both D# and Eb, you need to put _both_ in the
music expression. (Something could be worked out for enharmonics, I
suppose.)
Anyway, hope this helps!
David
\version "2.18.2"
#(define (get-pitch elt)
(ly:music-property elt 'pitch))
#(define (extract-pitches lst result)
(cond
((null? lst) result)
((ly:pitch? (get-pitch (car lst)))
(set! result (append result (list (get-pitch (car lst)))))
(extract-pitches (cdr lst) result))
((ly:music-property (car lst) 'elements)
(append
(extract-pitches (ly:music-property (car lst) 'elements) result)
(extract-pitches (cdr lst) result)))
(else (extract-pitches (cdr lst) result))))
colorPitches =
#(define-music-function (parser location mus col) (ly:music? color?)
(let* ((music-list (extract-named-music mus '(EventChord NoteEvent)))
(pitch-list (extract-pitches music-list '())))
#{
\override NoteHead.color =
#(lambda (grob)
(let ((pitch (ly:event-property (ly:grob-property grob 'cause) 'pitch)))
(if (member pitch pitch-list)
col)))
#}))
%%%%%%%%%%%%%%%%%%%%%%%% EXAMPLE %%%%%%%%%%%%%%%%%%%%%%%%%%
playerI = \relative c'' { g bes }
playerII = \relative c' { <c d> dis } % works for chords too
upper = \relative c' {
c4 cis d dis e f fis g gis a bes b c
}
\score {
\new Staff \upper
\layout { }
}
\score {
\new Staff {
\colorPitches \playerI #green
\upper
}
\layout { }
}
\score {
\new Staff {
\colorPitches \playerII #red
\upper
}
\layout { }
}
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user