On Thu, May 28, 2015 at 6:43 AM, Peter Gentry <peter.gen...@sunscales.co.uk> wrote:
> Thankyou David but how is color associated with NoteHead? > > I hope these ramblings of a gnarled old scheme/Lily tyro can be of general > interest.... > > I'm guessing that 'tweaks is some sort of switch to open up properties of > the current music object. > You've seen http://lilypond.org/doc/v2.18/Documentation/notation/the-tweak-command? Any usage of \tweak in the ly file would appear in the 'tweaks list in the music representation. Here, instead of using \tweak in the file, we're achieving the same result by modifying the music representation directly. To see the music representation (basically what LilyPond does to your ly code to make it more digestible) wrap various music expressions in \displayMusic. For example: \displayMusic { \tweak NoteHead.color #red c''4 } Note how the tweak is represented. > In this case "pitch" is a property of 'NoteEvent and I'm guessing that > color here is just NoteHead colour not NoteStem because NoteStem is not > within the NoteEvent including 'pitch. > > NoteStem color may be available in a tweak of another music object > or possibly supplied by another bit of code (engraver??). > I do not know how code a "tweak" for stem color (apart from an override in > the Lily .ly file) maybe you can't (anyway I don't want to). > Well, you'd tweak Stem. And once again, \displayMusic will show you what is done with your ly code: \displayMusic { \tweak Stem.color #blue c''4 } > Also AFSIU > don't know this one :) > "ly:music-property" extracts various elements of the current music item > (possibly contained in a deeper Lily code), and allows user scheme to > extract data from the current music object. > > ly:music-set-property! does the reverse? > Basically. > *This part of my script kindly supplied by Thomas Morley* > > (if (ly:pitch? p) > (let ((new-pitch (naturalize-instrument-range p instrument))) > (ly:music-set-property! music 'pitch new-pitch) > (if (and (not (equal? p new-pitch)) (color? my-color)) > (ly:music-set-property! music 'tweaks > (acons > 'color my-color > (ly:music-property music 'tweaks)))))) > In line 3 a pitch is written to the music event it may be the old pitch or > a new pitch. > In line 4 further action is taken if the pitch has been changed, first the > variable my-color (previously defined) is type checked > In line 5 'tweaks is inserted into the current music object. > lines 6 - 8 are a bit obscure somehow the current color is replaced by > my-color but how? > > Cannot find a definition for acons but it must be a variant of cons > ("consists") it occurs 8 times in snippets and once in notation and is > clearly the way to "tweak" associating the Lily 'color with the user > supplied color my-color. > You have to look to sources specifically devoted to Scheme. http://www.gnu.org/software/guile/docs/docs-1.8/guile-ref/Adding-or-Setting-Alist-Entries.html#index-acons-1603 Rather confusingly the format of color has many guises (x11-color 'red), (1 > 0 0), simply 'red (no pun intended) and notehead colour can also be > approached via a grob. The notehead grob must be somehow implied in the > (make-music ..... > The NoteHead grob will ultimately be made as a result of processing the NoteEvent. (As will a Stem, any Dots, an Accidental, etc.) Various different approaches to Notehead color are evident in the snippet > repositry agin not much detailed explanation is to be found. > http://www.lilypond.org/doc/v2.18/Documentation/learning/visibility-and-color-of-objects#the-color-property > upline = > #(let ((m (make-articulation "stopped"))) > (set! (ly:music-property m 'tweaks) > (acons 'font-size 3 > (acons 'stencil (lambda (grob) > (grob-interpret-markup > grob > (make-draw-line-markup '(0 . 1)))) > (ly:music-property m 'tweaks)))) > m) > \relative c' { > a'4^\upline a( c d')_\upline > } > > > which results in > > (make-music > 'RelativeOctaveMusic > 'element > (make-music > 'SequentialMusic > 'elements > (list (make-music > 'NoteEvent > 'articulations > (list (make-music > 'ArticulationEvent > 'direction > 1 > 'tweaks > (list (cons (quote font-size) 3) > (cons (quote stencil) #<procedure #f (grob)>)) > 'articulation-type > "stopped")) > 'duration > (ly:make-duration 2) > 'pitch > (ly:make-pitch 0 5)) > (make-music > 'NoteEvent > 'articulations > (list (make-music > 'SlurEvent > 'span-direction > -1)) > 'duration > (ly:make-duration 2) > 'pitch > (ly:make-pitch 0 5)) > (make-music > 'NoteEvent > 'pitch > (ly:make-pitch 1 0) > 'duration > (ly:make-duration 2)) > (make-music > 'NoteEvent > 'articulations > (list (make-music > 'SlurEvent > 'span-direction > 1) > (make-music > 'ArticulationEvent > 'direction > -1 > 'tweaks > (list (cons (quote font-size) 3) > (cons (quote stencil) #<procedure #f (grob)>)) > 'articulation-type > "stopped")) > 'duration > (ly:make-duration 2) > 'pitch > (ly:make-pitch 2 1))))) > Please format this--it's really hard to digest. With gmail, "Paste as plain text" rather than "Paste" does the trick for me. Maybe there's a similar option with Outlook? > > AFAICS tweaks are not documented properly anywhere - some of the > possible tweaks are presented without detailed explanation in the notation > and snippet manuals - is there another source of information? > Please see the link above. Hope this helps-- David
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user