[Top][All Lists]

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

Question about scheme engravers

From: Eric Knapp
Subject: Question about scheme engravers
Date: Mon, 18 Jan 2010 15:41:17 -0600

Hello, everyone.

I'm working on creating engravers in scheme. I have the example from

In the example file named, "" there is this piece of

(cons 'rest-event (lambda (engraver event)
            ((x (ly:engraver-make-grob engraver 'TextScript event)))
            (display (list "caught event" event "\ncreate:\n" x "\n"))
            (ly:grob-set-property! x 'text "hi"))

If there's a rest in the notation code like this, "<c-2\6>1 r2", then
the above display function will output this:

    (caught event #<Prob: Stream_event C++: Stream_event((music-cause
    . #<Prob: Music C++: Music((length . #<Mom 1/2>) (elements)
    (duration . #<Duration 2 >) (origin . #<location>))((display-methods #<procedure #f (rest
    parser)>) (name . RestEvent) (types general-music event
    rhythmic-event rest-event)) > ) (length . #<Mom 1/2>) (elements)
    (duration . #<Duration 2 >) (origin . #<location>))((class . rest-event)) >

Here's my question. How do I access elements in the event? For
example, the duration of the rest is shown above as, "(duration .
#<Duration 2>)". I would like to have an "if" statement look at the
duration variable and do something based on the value. What would an
if for that look like?

As you can probably tell, I'm also learning scheme. I've been looking
for a reason to learn scheme and the new capability of writing scheme
engravers has hooked me!

Thanks for the help in advance, this is getting exciting.


reply via email to

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