lilypond-user
[Top][All Lists]
Advanced

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

Re: Tweaking in an engraver


From: David Kastrup
Subject: Re: Tweaking in an engraver
Date: Fri, 17 Jul 2015 23:15:03 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Timothy Lanfear <address@hidden> writes:

> I'd like an engraver that changes the colour of the note head if the
> pitch meets certain conditions. If the note has an existing tweak,
> then I can add to or override the tweak; but the note colour is
> unchanged for a note without a tweak. Looking at the output of
> display-scheme-music, the only difference is in the order of the
> elements in the NoteEvent. I succeeded in writing an engraver using
> acknowledgers but it takes more digging into the grob data structure
> to extract the pitch of the note.
>
> \version "2.19.21"
>
> colourEngraver =
> #(lambda (context)
>  (make-engraver
>    (listeners
>      ((note-event engraver event)
>       (let* ((m (ly:event-property event 'music-cause))
>              (tweaks (ly:music-property m 'tweaks)))
>         (ly:music-set-property! m 'tweaks (assoc-set! tweaks 'color red))
>         (display-scheme-music m))))))

That's rather confused.  Why are you accessing music-cause in the first
place?  There is no point in messing with the music when an event has
already been created from it.  That is certain not to work.  Instead
work with the 'tweaks event property directly.  You won't be able to
call display-scheme-music on it but LilyPond will actually work with it.

-- 
David Kastrup



reply via email to

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