[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Notehead color on programmed pitch change
From: |
Peter Gentry |
Subject: |
RE: Notehead color on programmed pitch change |
Date: |
Thu, 28 May 2015 12:43:16 +0100 |
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.
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).
Also AFSIU
"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?
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.
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 .....
Various different approaches to Notehead color are
evident in the snippet repositry agin not much detailed explanation is to be
found.
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)))))
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?
[...]
(make-music
'SequentialMusic
'elements
(list (make-music
'NoteEvent
'duration
(ly:make-duration 0)
'pitch
(ly:make-pitch 0 0))
(make-music
'NoteEvent
'tweaks
(list (list (quote color) 1.0
0.0 0.0))
[...]
Still not sure how to interpret (list (list....... But as
long as Lily does.....:)
We're simply creating a nested
list:
(list (quote color) 1.0 0.0 0.0)
==>
(color 1.0 0.0 0.0)
(list (list (quote color) 1.0 0.0 0.0))
==>
((color 1.0 0.0 0.0))
By the way, (quote color) is just "longhand"
for 'color
Hope that helps,
David