lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Accidentals not changing colour


From: Thomas Morley
Subject: Re: Accidentals not changing colour
Date: Thu, 13 Jun 2013 00:47:27 +0200

2013/6/13 David Kastrup <address@hidden>:
> Thomas Morley <address@hidden> writes:
>
>> I tried it different:
>> (Note the version, it doesn't work with 2.16.2)
>>
>> \version "2.17.20"
>>
>> coloraccidentals =
>> \override NoteHead #'color =
>>   #(lambda (grob)
>>     (let* ((acc (ly:grob-object grob 'accidental-grob))
>>            (glyph-name
>>               (if (ly:grob? acc)
>>                   (ly:grob-property acc 'glyph-name)
>>                   "."))
>>            (which-acc (cadr (string-split glyph-name #\.))))
>>            (display glyph-name)
>
> That's distasteful and backwards.

lol

> Why don't you look at
>
> (ly:event-property (event-cause grob) 'pitch)
>
> instead?  That does not require the accidental grob to have been
> calculated and does not depend on accidental names.

This is for sure not a good code. I posted it (too) fast in order to
ask why it works at all.

>>     (cond ((string=? which-acc "sharp")
>>            red)
>>           ((string=? which-acc "flat")
>>            cyan))))
>>
>> m = \new Staff \relative c' { c8\f ces^"xy" cis <c cis'-1\2 ces'>\p }
>>
>> \new Score \with { \coloraccidentals }
>>         <<
>>                 \m
>>                 \m
>>         >>
>>
>>
>> Though I wonder why it works. It's an override and not a tweak, but it
>> colors NoteHeads different even in chords.
>> Have I missed something?
>
> Why would it depend on chords?  Chords just group stuff at the music
> expression level.  They are already dissolved at the stream event level:
> event-chord-event does not make it beyond the Event_chord_iterator.
>
> Regarding "you can't use overrides for notes within chords": that is
> actually "you can't use overrides for _individual_ notes within chords"

This was not completely clear to me.

> since overrides travel through context properties while tweaks travel
> through events.  Now here you are overriding the NoteHead.color property
> with a callback function, and indeed every note within the chord will
> use the same callback.  But that does not mean that the callback needs
> to arrive at the same value for every note in a chord.
>
> It just means that \coloraccidentals will apply to every note inside of
> a chord.  Unless you use \single\coloraccidentals on a note inside of a
> chord, of course...
>
> --
> David Kastrup

Thanks for your explanation.

-Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]