On 11/05/2013 07:51 PM, David Kastrup wrote:
Bric <b...@flight.us> writes:
On 11/05/2013 03:08 PM, David Kastrup wrote:
Paul Morris <p...@paulwmorris.com> writes:
But I think what you really want is a music function:
\version "2.17.29"
boo =
#(define-music-function
(parser location the-music)
(ly:music?)
#{
\override NoteHead.color = #red
#the-music
\revert NoteHead.color
#})
\relative c' { c4 d e f \boo { g a b } c d e }
For such fixed override/revert pairings you should write
\temporary\override in the music function instead of just \override:
otherwise any previous \override NoteHead.color = #blue will get
overwritten and not get restored afterwards.
You rock! This forum rocks! Lilypond rocks!
That said: how do I parametrize \boo ?
With the color as parameter, for example, for something like:
c4 d e f \boo #'red { g a b } c d e f8 g \boo #'blue { b d a4 d }
dis e fis
I realize I'm completely clueless about the syntax
boo =
#(define-music-function
(parser location color the-music)
(color? ly:music?)
#{
\temporary \override NoteHead.color = #color
#the-music
\revert NoteHead.color
#})
But colors are not symbols but triplets. The default colors
red/blue/black... are stored in variables of that name. So you'd have
to write
\boo #red { g a b } ...
rather than \boo #'red ...
This is so awesome!
So, can one throw in conditionals?
(1) Can one, for instance, check/manifest the pitch and duration of
'#the-music' ? And based on those values are, write something or not?
(2) And how DOES one write something extra? For example, add a note, or
add a \markup (again, conditionally, perhaps). I tried adding variants
of the following...
boo =
#(define-music-function
(parser location color the-music)
(color? ly:music?)
#{
\temporary \override NoteHead.color = #color
#the-music
(^\markup "C")
\revert NoteHead.color
#})
but none of them work. Obviously, I don't know where scheme ends and
lilypond code begins, in the above, and I don't even know scheme that
well. (By the way, I think I read the relevant parts of the
documentation, as much as I could find. I couldn't find stuff on this
level)
(3) Is "#the-music" an object, with properties and stuff, and how does
one access/modify those properties?
thanks.
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user