I've been using this for a while now and sometimes the lyrics are randomly coloured black instead of being associated with the note colour. I've tried to find a pattern to it but there doesn't seem to be one. Anyone have any ideas?
On 27 November 2016 at 16:42, Jack Mackenzie <[email protected] > wrote: > Wonderful! Works perfectly. Thank you very much. > > On 27 November 2016 at 13:26, Thomas Morley <[email protected]> > wrote: > >> 2016-11-27 2:40 GMT+01:00 Jack Mackenzie <[email protected] >> >: >> > I'm trying to put together an engraver for educational purposes, with >> > noteheads coloured according to a particular scheme, and lyrics >> following >> > this colouring. >> > >> > I've used the snippet for notehead colouring successfully >> > (http://lsr.di.unimi.it/LSR/Snippet?id=572), using "\override >> NoteHead.color >> > = #color-notehead", but have no idea how to get the lyrics to follow the >> > same colour scheme without changing each word individually. I took a >> punt >> > but using "override LyricText.color = #color-notehead" didn't work. >> > >> > Anyone got any clues to whether my idea is possible and if so how? >> > >> > Thanks >> >> >> Hi Jack, >> >> how about below? >> Not an engraver, seems to work, tho'. >> >> \version "2.18.2" >> >> %Association list of pitches to colors. >> #(define color-mapping >> (list >> (cons #{ c' #} (x11-color 'red)) >> (cons #{ cis' #} (x11-color 'green)) >> (cons #{ des' #} (x11-color 'green)) >> (cons #{ d' #} (x11-color 'blue)) >> (cons #{ dis' #} (x11-color 'cyan)) >> (cons #{ e' #} (x11-color 'red)) >> (cons #{ eis' #} (x11-color 'green)) >> (cons #{ fes' #} (x11-color 'red)) >> (cons #{ f' #} (x11-color 'green)) >> (cons #{ fis' #} (x11-color 'blue)) >> (cons #{ ges' #} (x11-color 'blue)) >> (cons #{ gis' #} (x11-color 'red)) >> (cons #{ aes' #} (x11-color 'red)) >> (cons #{ a' #} (x11-color 'green)) >> (cons #{ ais' #} (x11-color 'blue)) >> (cons #{ bes' #} (x11-color 'blue)) >> (cons #{ bis' #} (x11-color 'red)))) >> >> %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) >> (let* ((pitch-color >> (pitch-to-color >> (ly:event-property (event-cause grob) 'pitch))) >> (pap-col-elts >> (ly:grob-object >> (ly:grob-parent >> (ly:grob-parent grob X) >> X) >> 'elements)) >> (elts-list >> (if (ly:grob-array? pap-col-elts) >> (ly:grob-array->list pap-col-elts) >> '())) >> (lyr-text >> (filter >> (lambda (g) >> (grob::has-interface g 'lyric-syllable-interface)) >> elts-list))) >> (for-each >> (lambda (lyr) >> (ly:grob-set-property! lyr 'color pitch-color)) >> lyr-text) >> (ly:grob-set-property! grob 'color pitch-color))) >> >> \score { >> << >> \new Voice = "voice" >> \relative c' { >> \override NoteHead.after-line-breaking = #color-notehead >> c8 b d dis ees f( g) aes >> } >> \new Lyrics \lyricsto "voice" { c b d dis ees f aes } >> >> >> } >> >> >> Cheers, >> Harm >> > >
_______________________________________________ lilypond-user mailing list [email protected] https://lists.gnu.org/mailman/listinfo/lilypond-user
